CUPS unable to automatically locate printer

After an update sometime ago, cups started to fail when trying to print to printers that were automatically detected. The printers address would show up as

   dnssd://Brother%20DCP-L2540DW%20series._ipp._tcp.local/?uuid=e3248000-80ce-11db-xxxx-xxxxxxxxx

When trying to print to such a printer, cups would give the following error:

Unable to locate printer 'BRWXXXXXX.local'

If you have avahi running, then you can run

lpinfo -v

to list all the network printers. This would show, for example

network ipp
network ipps
network socket
file cups-pdf:/
direct hp
network lpd
network http
network https
network smb
direct hpfax
network dnssd://Brother%20DCP-L2540DW%20series._ipp._tcp.local/?uuid=e3248000-80ce-11db-xxxx-xxxxxxxxx
network lpd://BRW1008B19C71E2/BINARY_P1

The problem is that the correct libraries were not installed; see this askubuntu page. It tells you that you need to install the nss-mnds library. This is some sort of dns service that is necessary for cups to function. Once you install it using

pacman -S nss-mdns

Edit the file

/etc/nsswitch.conf

so that the hosts line contains.

   hosts: files mdns_minimal dns mdns