140

In Raring, everytime I connect to the network, Cups installs all the printers in the network automatically, some more than once.

Furthermore, I connect a USB printer to the laptop every now and then. Even though the printer is configured already, another printer is added to the list.

I wish to disable this feature and allow only manual installation of printers. How do I go about it?

To Do
  • 15,893
  • Did you figure out the answer? I am having similar problems on 14.04 and the answers have not worked for me here. My question is at http://askubuntu.com/questions/477082/hide-remove-network-printers-from-printing-dialog – Xu Wang Jul 16 '14 at 22:32
  • No, I didn't want to disable avahi-daemon and I'm no longer connected to the same network. There are no network printers where I am now. – To Do Jul 17 '14 at 10:16
  • How do I get rid of all the printers it installed? – khatchad Oct 30 '19 at 13:48
  • 1
    @RaffiKhatchadourian before disabling it (or after temporarily re-enabling it) I turned off my wifi and they went away. Then I disabled it with the wifi off. PS: Hi! – Michael Mandel Dec 10 '19 at 16:56
  • 2
    I don't understand how it is even a feature – Kiwy Jul 27 '20 at 15:47
  • Linked https://askubuntu.com/a/1436064/456438 – Dominic108 Oct 19 '22 at 09:06

10 Answers10

144

I just discovered a, possibly optimal, solution to this mess. There is as service called "cups-browsed" which apparently is responsible for going out on the network and finding all the printers it can locate and install them for you (gee - thanks --NOT). Since this is an Upstart/Systemd job, you can stop the service with:

For Ubuntu versions 15.04+ (using systemd)

sudo systemctl stop cups-browsed

Followed by:

sudo systemctl disable cups-browsed

You may still start/stop the service manually if you wish with:

sudo systemctl start cups-browsed
sudo systemctl stop cups-browsed

For Ubuntu versions prior to 15.04 (using upstart)

sudo service cups-browsed stop

Even better, you can prevent the service from ever starting again by adding a simple text file to /etc/init that contains the single word manual. The file must be named cups-browsed.override

So, just start up gedit with

gksudo gedit /etc/init/cups-browsed.override

put manual in the first and only line and save the file.

On the next Reboot, the service will not be re-started. However, you need not reboot if you've already stopped the service. Once you've placed this file in /etc/init, the service can only be started manually (if and when you need/want it) using:

sudo service cups-browsed start
-or-
sudo service cups-browsed stop`

I have tested this over one reboot. Printing still works fine and so far I am not getting several hundred printers installed anymore after the reboot. Just the ones I installed manually show up.

To Do
  • 15,893
Steve Besch
  • 1,596
56

In /etc/cups/cups-browsed.conf, set directive:

BrowseProtocols none

Afterwards, run service cups-browsed restart and service cups restart. There should be no printers visible, except those you've added yourself.

jumpnett
  • 6,185
  • This is the most straightforward solution for 15.10. – Mustafa Oct 27 '15 at 19:19
  • 1: that is for sharing the current device's printer(s) to the network, not for showing network printers. – Alex R Apr 18 '16 at 07:50
  • Correct, only step 2 is necessary, and is more correct than the hack in the currently upvoted answer. Please fix your answer to avoid adding confusion to an already confusing answer! – kiko Jul 20 '16 at 18:07
  • There was one particular printer on my network that kept re-adding itself after being deleted. I set this option, rebooted, and it fixed the issue. I am using Debian 9. Thanks – jbrock Aug 31 '17 at 14:40
  • 2
    this solution is work for 18.04 – eetsurt Jan 11 '19 at 06:04
  • This should be the accepted answer. Works great for 20.04 LTS – Patrick Rynhart Aug 12 '20 at 04:28
  • There are two mechanisms how Ubuntu auto-adds printers. The first one is cups-browsed and can be stopped like this. The second one is cups adding printers itself. There is no easy way to stop the second one except with a load of messy patches. Just braindead. – Thomas Wana Oct 22 '20 at 07:37
  • BrowseRemoteProtocols none in my case – Pau Coma Ramirez Apr 01 '21 at 17:01
  • This should be the accepted answer. This works with 25.04 – JamesWat Jul 01 '25 at 04:14
20

As mentioned earlier, this is now done in the client-side cups libraries (ie libcups.so, which GNOME and KDE apps link against) and not in the cupsd server. So changing the "Browse" settings in the cups server won't work.

$ ldd /usr/lib/x86_64-linux-gnu/libcups.so.2
...
libavahi-common.so.3 => /usr/lib/x86_64-linux-gnu/libavahi-common.so.3
libavahi-client.so.3 => /usr/lib/x86_64-linux-gnu/libavahi-client.so.3
...

IE this behaviour (of showing remote printers in the Print dialog box) happens even if you turn off your local cups server. You can disable it by turning off the avahi service, but that will disable all zeroconf/mdns related functionality.

However, there is at least a way to turn off most of avahi's functionality (including adding remote printers into the CUPS clients) while keeping the DNS functionality (eg when looking up foo.local-style host names):

edit /etc/avahi/avahi-daemon.conf and in the [server] section, add enable-dbus=no then restart the avahi-daemon service.

John McP
  • 201
  • 2
  • 2
  • If a wired connection is not networked with other computers, it may not benefit from avahi-daemon running all of the time. If not used, it can be uninstalled. – noobninja Aug 19 '15 at 04:38
  • Out of all the answers on the page, this is the only one that worked for me to solve: How do I get rid of a ghost printer in Gnome? – Stephen Ostermiller Nov 20 '15 at 12:57
  • 2
    Why does enable-dbus=no prevent avahi discovery of printers and what other avahi functionality will be affected by this config change? – gene_wood Dec 23 '15 at 19:09
  • 2
    I made this change and it did indeed prevent auto discovered printers from showing up in the list of printers, however my goal was to make the printer dialog come up more quickly (it normally takes 5 to 10 seconds). This change made it take longer for the printer dialog to come up (long enough that Ubuntu dimmed the dialog thinking that it wasn't responding). Hmm. – gene_wood Dec 23 '15 at 19:26
  • 1
    Worked for me. But I have the same problem as gene_wood. It takes ~5s to load the much-shortened printer list. – Hoseung Choi Feb 20 '18 at 09:43
  • 1
    Try adding browse-domains=local.local in your avahi-daemon.conf instead of disabling d-bus. That should avoid the delay. – istepaniuk May 13 '20 at 17:09
  • 2
    I have had a very nasty side-effect by "sing enable-dbus=no". Libreoffice writter stalled for 30-40 seconds every time I open some files. LO tries to find the printer at file opening involving avahi somehow and stalled for 30 to 40 seconds each time. New files have no problem if they have not been printed yet. The lag also happen each time I enter the printing menu in LO or the printer configuration menu in Ubuntu. Tested in 18.04 and 20.04. It took me more than a year to find out it was related to disabling dbus in avahi, so I do not recommend to use this approach. – jjchico Sep 17 '20 at 14:08
  • I tried the other solution with more votes on Ubuntu 22.04 without success. This one worked – Camilo Rada Mar 31 '24 at 00:18
  • For a solution that preserves avahi's functionality while ignoring not-installed printers in print-dialogs s. my answer here: https://askubuntu.com/a/1544292 – spawn Mar 22 '25 at 23:12
16

I tried all of the above. Modifying Cups did not work in Linux Mint 20, which is based on Ubuntu 20.4. Apparently, Ubuntu and Mint no longer use Cups for Printer discovery, but instead now use Avahi. I think it is a Systemd thing. Setting enable-dbus=no in avahi-daemon.conf somewhat worked, but caused the print menu in LibreOffice to take a long time (maybe 20-30 sec.) to show up, and thus was not a good solution.

The following did work, however, very well:

sudo nano /etc/avahi/avahi-daemon.conf

In that file:

change “use-ip4=yes” to “use-ip4=no”

change “use-ip6=yes” to “use-ip6=no”

Now, only printers that I added manually show up in the "Printers" control panel (Printers-localhost), the HPLIP Toolbox and LibreOffice.

  • 1
    This is a piece of genius! It disable avahi without disabling it! :-) – ciampix Jan 22 '21 at 07:55
  • 1
    @ciampix yes it does get the job done for me in Ubuntu 20.04 - except I have found out, that if I configure both ipv4 and ipv6 to "no", upon systemctl start avahi-daemon, the daemon fails to start. Thus, the same effect would probaby be achieved simply by systemctl stop avahi-daemon, maybe followed by a "disable" to prevent automatic re-appearance on the next boot... – frr Jun 10 '21 at 09:57
9

The cups client libraries now also get a list of network printers from Avahi (which implements the protocol known variously as zeroconf or Bonjour or mdns or dns-sd). In older versions of cups, this was only done by the cups server.

You can see what is being broadcast on your network with a shell command like avahi-browse -a | grep Printer

You can disable avahi with sudo service avahi-daemon stop, but that will stop all zeroconf based setup, not just printers.

Stormvirux
  • 4,536
6

To disable it simply open terminal Ctrl+Alt+T and type

 sudo cupsctl --no-remote-printers

or to edit the

 /etc/cups/cupsd.conf

and set

Browsing Off

This solution was found here

Some newer Ubuntus (15.04 and up) may need this command instead:

sudo cupsctl --no-share-printers
dotancohen
  • 2,864
Simon
  • 4,843
  • 5
    I still have this problem, although my cupsd.conf already contains "Browsing Off". Running the cupsctl leads to the following error: cupsctl: Unknown option "--no-remote-printers" Usage: ... – Catalin Hritcu Oct 21 '13 at 12:16
  • Forgot to mention, I'm on Ubuntu 13.10 – Catalin Hritcu Oct 21 '13 at 15:22
  • 1
    @CatalinHritcu, How about setting BrowseLocalProtocols none? – user.dz Mar 20 '14 at 12:10
  • 1
    this is for the local machines sharing not for not adding remote printers. – Alex R Apr 18 '16 at 07:50
  • It's helpful to know that setting 'Browsing Off' will immediately disable any printers you're sharing AND will not prevent remote printers from being added to CUPS – Brandon Nov 08 '24 at 11:04
4

It's quite simple to make it stop.

  1. Remove the unwanted printers. Then:

    sudo nano /etc/cups/cups-browsed.conf
    
  2. Change this line: BrowseRemoteProtocols dnssd cups (or whaterver is after it) to none so it reads: BrowseRemoteProtocols none .

  3. Then save the file and reboot.

Solved the problem for me.

user.dz
  • 49,295
1

Found the solution, if you disable bonjour in HP (probably other printers too) the mystery printer detection is an issue of the past.

  • After being annoyed by this problem for MONTHS, this ended up being by far both the simplest solution and most reliable solution. – Patrick F Aug 12 '21 at 05:30
1

The accepted answer by @steve-besch works but is incomplete. As explained below, to me the best approach appears to be patching gtk and and optionally libcups2 in addition to disabling cupsd-browsed.

1. Disable cupsd-browsed as already described

sudo systemctl stop cups-browsed
sudo systemctl disable cups-browsed

You can verify that this works using the printing configuration utility system-config-printer.

2. Patch Gtk such that its print-dialog no longer uses avahi

Create patch print_dialog_without_avahi_discovered_printers.patch:

--- a/modules/printbackends/cups/gtkprintbackendcups.c
+++ b/modules/printbackends/cups/gtkprintbackendcups.c
@@ -4008,7 +4008,7 @@
           g_source_set_name_by_id (cups_backend->list_printers_poll, "[gtk+] cups_request_printer_list");
         }

  •  avahi_request_printer_list (cups_backend);
  •  // Do NOT add random network printers!    avahi_request_printer_list (cups_backend);
    } }

Reinstall gtk with the applied patch:

sudo apt build-dep libgtk-3-dev
apt source libgtk-3-dev
cd $(find gtk* -maxdepth 0 -type d)
git apply --reject --whitespace=fix ../print_dialog_without_avahi_discovered_printers.patch
debuild -b  -us -uc  --no-pre-clean
cd ..
sudo apt install --reinstall ./libgtk-3-0_*.deb  
# do not update (dist-upgrade)
# sudo apt-mark hold libgtk-3-0

Now launch a new Evince PDF Viewer instance and verify that only printers listed in the system-config-printer app show up in the print dialog.

3. Patch libcups2 such that KDE/Libreoffice print dialogs no longer use avahi

Create patch no_discovered_printers.patch:

--- a/cups/dest.c
+++ b/cups/dest.c
@@ -1689,7 +1689,7 @@
   data.num_dests = 0;
   data.dests     = NULL;

  • if (!httpAddrLocalhost(httpGetAddress(http)))
  • if (1 || !httpAddrLocalhost(httpGetAddress(http))) { /*
    • When talking to a remote cupsd, just enumerate printers on the remote

Reinstall libcups2 with the applied patch:

sudo apt build-dep libcups2
apt source libcups2
cd $(find cups-* -maxdepth 0 -type d)
git apply --reject --whitespace=fix ../no_discovered_printers.patch
debuild -b  -us -uc  --no-pre-clean
cd ..
sudo apt install --reinstall  ./libcups2_*_amd64.deb





do not update (dist-upgrade)

sudo apt-mark hold libcups2

Now launch a new Okular instance and verify that only printers listed in the system-config-printer app show up in the print dialog.

Background

As several answers here point out, printers that were not installed still appear in the print dialog of e.g. the PDF-Viewer Evince or Libreoffice even after having disabled the cups-browsed service. This could be prevented, by stopping the avahi daemon that actually finds these printers in the network: sudo service avahi-daemon stop. However, I strongly advise against this -- for instance it breaks Gnome's scanning app such that it is no longer able to scan and I expect other apps to break as well. Unfortunately, there appears to be no official way to disable only cups filtering in avahi (s. here). Instead, it was suggested to disable this on the level of the printing dialog. S. also here.

spawn
  • 261
0

Try:

  1. Open http://localhost:631/admin/ → Edit Configuration File or Edit /etc/cups/cupsd.conf

  2. Change:

    # Show shared printers on the local network.
    Browsing Off
    BrowseLocalProtocols none
    

Reference: cupsd.conf: BrowseLocalProtocols

user.dz
  • 49,295
  • 1
    Unfortunately, this didn't stop remote printers from being added for me. – azimut Nov 04 '14 at 10:04
  • 2
    It's helpful to know that setting 'Browsing Off' will immediately disable any printers you're sharing AND will not prevent remote printers from being added to CUPS – Brandon Nov 08 '24 at 11:03