Score:1

dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use

es flag

I'm trying to set up dnsmasq on AWS Ubuntu 20.4 by following this link.

However, I can't seem to get around the error dnsmasq: failed to create listening socket for port 53: Address already in use

I've tried the steps in these posts with no success:

  1. dnsmasq: failed to create listening socket for port 53: Address already in use

  2. https://discourse.pi-hole.net/t/dnsmasq-failed-to-create-listening-socket-for-port-53-permission-denied/16436

  3. https://jonamiki.com/2020/01/29/dnsmasq-failed-to-create-listening-socket-for-port-53-address-already-in-use/

  4. dnsmasq : failed to create listening socket for port 53: Address already in use

The only thing that has had any obvious impact has been sudo systemctl stop systemd-resolved.service which changed the error message from dnsmasq: failed to create listening socket for port 53: Address already in use to dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use

I'm not sure what's actually running on 53 because, if I run sudo ss -alpn sport = 53 src 127.0.0.1 there is no output, nothing is apparently listening on port 53. However, If I run sudo ss -lp "sport = :domain" my output is:

Netid       State        Recv-Q       Send-Q             Local Address:Port               Peer Address:Port      Process                                  
udp         UNCONN       0            0                        0.0.0.0:domain                  0.0.0.0:*          users:(("dnsmasq",pid=2059,fd=4))       
udp         UNCONN       0            0                           [::]:domain                     [::]:*          users:(("dnsmasq",pid=2059,fd=6))       
tcp         LISTEN       0            32                       0.0.0.0:domain                  0.0.0.0:*          users:(("dnsmasq",pid=2059,fd=5))       
tcp         LISTEN       0            32                          [::]:domain                     [::]:*          users:(("dnsmasq",pid=2059,fd=7))    

My /etc/dnsmasq.conf looks like:

no-resolv
server=8.8.8.8#53
listen-address=127.0.0.1
cache-size=50

I tried enabling bind-interfaces in /etc/dnsmasq.conf which made no difference.

And I also tried to make sure to stop systemd-resolved service and I masked it so auto start on reboot.

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

Again, no difference.

Checking sudo systemctl dnsmasq.service returns:

Unknown operation dnsmasq.service.
ubuntu@ip-172-31-27-116:~$ sudo systemctl status dnsmasq.service
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
     Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2022-02-13 19:55:05 UTC; 36s ago
    Process: 3381 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
    Process: 3382 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=2)

Feb 13 19:55:04 ip-172-31-27-116 systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Feb 13 19:55:05 ip-172-31-27-116 dnsmasq[3381]: dnsmasq: syntax check OK.
Feb 13 19:55:05 ip-172-31-27-116 dnsmasq[3382]: dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use
Feb 13 19:55:05 ip-172-31-27-116 dnsmasq[3382]: failed to create listening socket for 127.0.0.1: Address already in use
Feb 13 19:55:05 ip-172-31-27-116 dnsmasq[3382]: FAILED to start up
Feb 13 19:55:05 ip-172-31-27-116 systemd[1]: dnsmasq.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Feb 13 19:55:05 ip-172-31-27-116 systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
Feb 13 19:55:05 ip-172-31-27-116 systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
WU-TANG avatar
cn flag
the --bind-dynamic flag gets me beyond the error. I am not making the effort to actually set it up or test it... So I don't know any further results. `dnsmasq -d --bind-dynamic -a 127.10.0.1` on the command line, got the service start and listen on the port... without the flag, I get the same error.
L23P avatar
es flag
`dnsmasq: cannot set --bind-interfaces and --bind-dynamic` is all I get.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.