Ubuntu port 53 already in use. How to free the DNS port

Don’t be suprised when you see Ubuntu is complaining port 53 is not avaiable. Most people won’t encounter this issue unless you are doing things with DNS. In default, port 53 is reserved by systemd-resolved

ubuntu

If you see errors like below and you have not done anything to use the DNS port. You are most likely affected by systemd-resol

failed to create listening socket for port 53: Address already in use [fail]

Error starting userland proxy: listen tcp4 0.0.0.0:53: bind: address already in use

You can confirm if you are affect by systemd-resol by checking listening ports and applications.

1
sudo netstat -tulpn | grep LISTEN

systemd-resol is listening on port 53.

1
2
3
tcp        0      0 127.0.0.53:53     0.0.0.0:*     LISTEN     18447/systemd-resol 
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 18411/sshd: /usr/sb
tcp6 0 0 :::22 :::* LISTEN 18411/sshd: /usr/sb

systemd-resolved is a system service that provides network name resolution to local applications. It implements a caching and validating DNS/DNSSEC stub resolver, as well as an LLMNR resolver and responder.

To stop systems-resolved using port 53 is easy

1. Edit /etc/systemd/resolved.conf set DNSStubListener to no

1
sudo nano /etc/systemd/resolved.conf

Your resolved.conf will looks like below. You can set DNS=8.8.8.8 to whatever DNS server you want the system to use. Without it your system won’t able to resolve any domain.

1
2
3
4
5
6
7
8
9
10
11
[Resolve]
DNS=8.8.8.8
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=no-negative
DNSStubListener=no
#ReadEtcHosts=yes
1
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

This command remove existing /etc/resolv.conf if it exist and create a symbolic link

3. Reboot your system.

Webpack Graphql compile error easy fix Let Docker and UFW Firewall work together

Comments