Failed to run: dnsmasq - Address already in use

(Johann) #1

lxc network set lxdbr0 ipv4.routes $routes

error: Failed to run: dnsmasq --strict-order --bind-interfaces --pid-file=/var/lib/lxd/networks/lxdbr0/ --except-interface=lo --interface=lxdbr0 --quiet-dhcp --quiet-dhcp6 --quiet-ra --listen-address= --dhcp-no-override --dhcp-authoritative --dhcp-leasefile=/var/lib/lxd/networks/lxdbr0/dnsmasq.leases --dhcp-hostsfile=/var/lib/lxd/networks/lxdbr0/dnsmasq.hosts --dhcp-range,,1h --listen-address=fd42:7bb5:714c:966::1 --enable-ra --dhcp-range ::,constructor:lxdbr0,ra-stateless,ra-names -s lxd -S /lxd/ --conf-file=/var/lib/lxd/networks/lxdbr0/dnsmasq.raw -u nobody: dnsmasq: failed to create listening socket for Address already in use

When I see this fail, I just retry and it works with no error.
Anyone saw this before?
Any idea ?

Error: Failed to run: dnsmasq - Address already in use
Error: Failed to run: dnsmasq - Address already in use
(Stéphane Graber) #2

That means that you have an existing DNS or DHCP server running on your machine which is binding all interfaces, preventing LXD from listening on lxdbr0.

sudo netstat -lnp | grep ":53 " should show you what it is (it’s often bind9/named).
Once you figure out what it is, you have two options:

  • Remove that conflicting DNS server (if you don’t actually need it)
  • Configure it to only bind to the interfaces you actually need it on

(Johann) #3

netstat -lnp | grep ":53 "

tcp 0 0* LISTEN 2005/dnsmasq
tcp6 0 0 :::53 :::* LISTEN 2005/dnsmasq
udp 0 0* 2005/dnsmasq
udp6 0 0 :::53 :::* 2005/dnsmasq

I’m not sure what to do here.


This says that there is a dnsmasq process that is binding to all network interfaces (*).
By doing so, the dnsmasq from LXD cannot start.

Give this a try,

  1. sudo systemctl stop dnsmasq so that the distro dnsmasq stops working.
  2. sudo systemctl restart lxd so that LXD restarts and LXD’s dnsmasq gets the chance to bind on the lxdbr0 network interface first.
  3. sudo systemctl start dnsmasq to start again the distro dnsmasq.

(Stéphane Graber) #5

In most cases, you don’t actually want a system-wide dnsmasq daemon.
The distro-managed dnsmasq daemons tend to be only bound to your loopback device.

Unless you remember installing/configuring that system-wide dnsmasq, I’d recommend just removing it with apt remove dnsmasq. Note that the dnsmasq package is different from the dnsmasq-base package, the former is the system-wide daemon, the latter is the per-interface dnsmasq which a bunch of packages (including LXD) use.

(Johann) #6


Removed dnsmasq , installed bind, installed dnsmasq-base and all seems fine now.

Thank you !

(Nicolas Quiniou Briand) #7


For the record, I got exactly the same behaviour after doing an installation of LXC (2.0.7) and LXD (3.9) under Debian Stretch 9.7.

For me, the running dnsmasq daemon was run by the installation of lxc.

My workaround was just to stop dnsmasq with systemctl stop dnsmasq as @simos said and re-run lxd init.