I was setting up a server as in the below link https://help.ubuntu.com/community/Dnsmasq

root@user-desktop:/etc/init.d# sudo apt-get install dnsmasq
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/15.4 kB of archives.
After this operation, 120 kB of additional disk space will be used.
Selecting previously unselected package dnsmasq.
(Reading database ... 146283 files and directories currently installed.)
Unpacking dnsmasq (from .../dnsmasq_2.59-4_all.deb) ...
Processing triggers for ureadahead ...
Setting up dnsmasq (2.59-4) ...
 * Starting DNS forwarder and DHCP server dnsmasq                                                                                                                                                            
dnsmasq: failed to create listening socket for port 53: Address already in use [fail]
invoke-rc.d: initscript dnsmasq, action "start" failed.

8 Answers 8


Check what's listening on port 53 (domain) with:

sudo ss -lp "sport = :domain"

Disable any service that is running on this port. It's usually systemd-resolved.

Here I make sure that you have stopped the systemd-resolved service. I'm going to also mask it so it doesn't auto start on reboot.

sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolved
sudo systemctl mask systemd-resolved

To undo what you did:

sudo systemctl unmask systemd-resolved
sudo systemctl enable systemd-resolved
sudo systemctl start systemd-resolved

Also sudo update-rc.d systemd-resolved disable might also stop it from auto starting on boot but I haven't tested it. Use defaults instead of disable to undo the command.

Note that systemd-resolved is an important component for name resolution. If you don't have any name resolution service properly running and configured you might encounter Temporary failure in name resolution.

Or you can change what port dnsmasq listens on, by editing the config file:

sudo nano /etc/dnsmasq.conf

Hit Ctrl+W and type listen-address= and hit enter.

Uncomment the line and add with a different port than 53 like:

  • sudo ss -lp "sport = :domain" Doesn't say 53 Jul 9, 2020 at 0:18
  • 1
    I followed this guide, but nothing seems to help me with by Ubuntu 20.04. When it starts ans when get console, dnsmawg is not started as described, because some process opens tcp-port 53 on start. If I try to start dnsmasc by hand as fast IO can do by 'sudo systemctl start dnsmasq' it succeed. I found out that avahi-daemon also opens port 53 (using commands 'sudo lsof -i TCP:53' and 'sudo netstat -vanp tcp | grep ':53'' I founde oud stat avahi-daemon open port 53 and I disabled it as described above, but no change. So I just added '/bin/systemctl start dnsmasq' to rc.local. It seems to help. Jun 9, 2021 at 14:55
  • 1
    @PhilipRego the “:domain” represents the default port for domain, which is 53 Apr 17, 2022 at 16:21

I get the same issue as you do. I think that it's true since 12.10, but this thread was closed before the release of 12.10.

Making some googling around (mostly inspired from here), I found this solution:

  • edit /etc/NetworkManager/NetworkManager.conf file with you lovest editor
  • comment the line dns=dnsmasq
  • restart the network manager : sudo service network-manager restart

But in your dnsmasq configuration (/etc/dnsmasq.conf), you have to be sure to listen the localhost DNS queries with the line listen-address=

If you change the configuration of dnsmasq, don't forget to run sudo /etc/init.d/dnsmasq restart

I hope this will help.

  • 2
    By commenting out dns=dnsmasq doesn't that defeat the purpose of installing DNSmasq. I made the listen-address= change and it seems to work fine now.
    – user232921
    Jan 7, 2014 at 22:32
  • 1
    No. You're keeping NetworkManager from starting dnsmasq and instead starting it independently.
    – MrMas
    Aug 27, 2019 at 15:07
  • i found dns= in /usr/lib/NetworkManager/conf.d/10-dns-resolved.conf however commenting out did not fix the dnsmasq: failed to create listening socket for Apr 9, 2020 at 23:58
  • I didn't have the line dns=dnsmasq in /etc/NetworkManager/NetworkManager.conf. I set listen-address= in /etc/dnsmasq.conf and restarted dnsmasq, but I still get the same port 53: address already in use error. Jul 9, 2020 at 0:26
  • Is it better to prevent NetworkManager from starting dnsmasq, or to disable the systemd service (systemctl disable dnsmasq) Does it make a difference other than which config gets used? And is NetworkManager choosing a better config?
    – trey-jones
    Oct 14, 2020 at 22:53

I had the same problem.

dnsmasq-base was installed and listened on port 53 preventing dnsmasq to start.

It is possible to use dnsmasq-base insead of dnsmasq for the same purpose: just use another config directory: the one placed in Network Manager folder:


My Solution: OP: Ubuntu 22.04

Step 1: Edit /etc/dnsmasq.conf

sudo nano /etc/dnsmasq.conf

Step 2: Change port 53 -> 5353

# Listen on this specific port instead of the standard DNS port
# (53). Setting this to zero completely disables DNS function,
# leaving only DHCP and/or TFTP.

# Set Listen address

Step 3: restart dnsmasq.service

sudo systemctl restart dnsmasq.service

If you don't want to screw up the resolver do it like this with rc.local.

Stop dnsmasq from auto starting.

servicectl disable dnsmasq

Create file /etc/rc.local or /etc/rc.d/rc.local depending on distro.

Set perms chmod +x /etc/rc.local

Edit file:

service systemd-resolved stop
service dnsmasq start

Disabling systemd-resolved on startup comes with issues. I believe it has something to do with the /etc/resolv.conf file but I'm not sure. All I know is that the first answer caused me a lot of problems and ultimately did not work at all. Simply stopping systemd-resolved then starting dnsmasq after full boot works perfect, at least on Mint. I can't speak on other distros.


try this: sudo fuser -k 53/tcp it will print you the process id of process bound on that port then kill it using: sudo kill -9 process-id


My solution for Ubuntu 22.04 (improving upon the solution provided by Murat Cakmak) by keeping both systemd-resolved and dnsmasq.

Basically, we run dnsmasq on a different address. So, /etc/dnsmasq.conf will have the following lines...

# If you want dnsmasq to listen for DHCP and DNS requests only on
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
# Repeat the line for more than one interface.
# Or you can specify which interface _not_ to listen on
# Or which to listen on by address (remember to include if
# you use this.)

# On systems which support it, dnsmasq binds the wildcard address,
# even when it is listening on only some interfaces. It then discards
# requests that it shouldn't reply to. This has the advantage of
# working even when interfaces come and go and change address. If you
# want dnsmasq to really bind only the interfaces it is listening on,
# uncomment this option. About the only time you may need this is when
# running another nameserver on the same machine.

The above can be automated using the following lines...

sed -i "s:^# \?\(listen-address=\):\1$DNSMASQ_ADD:" /etc/dnsmasq.conf
sed -i "s:^# \?\(bind-interfaces\):\1:" /etc/dnsmasq.conf

Make sure to restart dnsmasq with...

systemctl restart dnsmasq

Then, let systemd-resolved to listen to dnsmasq for any queries. This can be done safely by creating a file under /etc/systemd/resolved.conf.d/ like the following...

[ ! -d /etc/systemd/resolved.conf.d ] && mkdir /etc/systemd/resolved.conf.d
[ ! -f /etc/systemd/resolved.conf.d/dnsmasq.conf ] && \
    echo -e "[Resolve]\nDNS=$DNSMASQ_ADD" > /etc/systemd/resolved.conf.d/dnsmasq.conf
systemctl restart systemd-resolved

For more info, please checkout the man pages of resolved.conf.d and resolved.conf. I hope that helps someone!


This can also occur if you have installed dnscrypt-proxy and you have systemd socket activation enabled. This can be problem when trying to use dnscrypt with systems such as run pi-hole which depend on dnsmasq running on port 53. This feature seems to be enabled by default on some distributions so it needs to be manually disabled as explained in the dnscrypt-proxy docs.

Here's the steps they suggest: You'll firstly need to set a new port for it to listen on by editing the dnscrypt-proxy config file and changing the listen_addresses (e.g. to listen on port 53533 use: listen_addresses = ['']:

sudo nano /etc/dnscrypt-proxy/dnscrypt-proxy.toml

Then you'll need to stop and disable the service that is binding and redirecting port 53 (doing the systemd socket activation), which is called dnscrypt-proxy.socket:

sudo systemctl stop dnscrypt-proxy.socket
sudo systemctl disable dnscrypt-proxy.socket

And then remove it from the dnscrypt-proxy.service and dnscrypt-proxy-resolvconf.service config files (by commenting out any references to dnscrypt-proxy.socket i.e. by adding the # comment symbol in front of any entries: e.g. #After=dnscrypt-proxy.socket #Requires=dnscrypt-proxy.socket #Also=dnscrypt-proxy.socket)

sudo nano /lib/systemd/system/dnscrypt-proxy.service
sudo nano /lib/systemd/system/dnscrypt-proxy-resolvconf.service

Then you'll be prompted to do a daemon-reload after editing the systemd config files:

sudo systemctl daemon-reload

And finally you can restart the dnscrypt-proxy.service:

sudo systemctl restart dnscrypt-proxy.service

And the init process will no longer be bound to port 53 and you'll only see dnscrypt-proxy attached to your configured port (or 53533 if you copied the above example).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .