The answer provided by malliaridis is correct when the printer connection is not broadcast by a printer in the network. Otherwise, it gets back anyway, because cups-daemon uses that information to update the printer connections stored locally. If you don't need this printer in your ubuntu desktop or laptop, the solution is to turn it off, disconnect it from the local network or prevent it from broadcasting itself in the network through Bonjour or anyother way used to broadcast a service in mDNS. In the same manner, if your computer is connected to a printer via the usb port as well as to another (or the same) printer via wifi, you will see two printers and if you delete them, they will be added back. This is to be expected. This is not a bug, but a feature.
However, the issue is also often that the same printer broadcast different connections using different protocols over the wifi. In that case, you see different "printers", but they are different wifi connections for the same printers, many of them often not working in your ubuntu device. These other connections might be needed by other devices in the local network. If they are all ubuntu systems, you can turn off in the printer all network features except the one needed by Ubuntu. (In the case of the HP Color Laser Jet M255, I kept the basic network such as ipv4, ipv6, DHCP together with Bonjour with either IPP or IPPS. But I only succeeded with IPP. If I used IPPS, another connection, which did not work, was also broadcast. Actually, it was sufficient to disable IPPS to avoid the printer being advertised twice.)
The avahi-daemon implements mDNS in Ubuntu. You can check the list of ipp printer connections broadcast on mDNS using avahi-browse -t _ipp._tcp
for IPP connections, avahi-browse -t _ipps._tcp
for IPPS connection and avahi-browse -at
for all connections regardless of the type. The -t
option makes the request terminates instead of continuing listening. Even if you reduce the number of network features in the printer, it might be broadcast more than once in mNDS, say under ipv4 and ipv6, etc., but the difference might be sufficient for it not to appear more than once in Settings->Printers and other applications.
The file /etc/cups/printers.conf
keeps printer connections that are not broadcast so that you can see the configured printers even when they are turned off. For example, if you have connected via usb to a printer, it will be kept there. The command lpstat -p
lists the configured printer connections including those in /etc/cups/printers.conf
. The cups daemon regularly updates this file using the information that is broadcast by the printers, but, as already explained, it will not remove all stored connections.
If after these modifications other printer connections still come back after you try removing them in http://127.0.0.1:631/printers/ or even with lpadmin -x
, you might need to remove them directly from /etc/cups/printers.conf
. It would be pointless to edit this file before the broadcast by the printers is taken care of. When you decide to edit it, you must stop the cups daemon service with sudo service cups stop
before doing so and restart cups with sudo service cups start
after.