Modern versions of Ubuntu use a systemd service called systemd-resolved to manage DNS lookups. As part of this service, Ubuntu automatically binds a local “stub listener” to port 53 (the standard DNS port) on the loopback address (127.0.0.53). This acts as a local caching DNS server for your operating system.
For standard desktop users, this is perfectly fine. However, if you are a developer or sysadmin trying to install your own DNS server (like BIND9, Dnsmasq, or a network-wide ad blocker like Pi-hole) directly onto your Ubuntu machine, the installation will immediately fail. Your new software will throw a “Port 53 is already in use” error because systemd-resolved is stubbornly holding onto the port.
To free up port 53 for your own applications, you must disable the hidden stub listener.
How to Disable the Stub Listener
You cannot simply kill the systemd-resolved service, as Ubuntu relies on it for internet connectivity. Instead, you must edit its configuration file.
- Open your terminal application (
Ctrl+Alt+T). - Open the resolved configuration file using nano (with root privileges):
sudo nano /etc/systemd/resolved.conf
- Look for the line that says
#DNSStubListener=yes. - Uncomment the line by deleting the
#symbol. - Change the “yes” to “no” so the line reads exactly:
DNSStubListener=no
- Save the file (
Ctrl+O,Enter) and exit nano (Ctrl+X).
How to Re-link Your resolv.conf
Because you disabled the local stub listener, your system can no longer query 127.0.0.53 for internet addresses. You must now tell Ubuntu to bypass the stub entirely and use the upstream DNS servers directly.
- Delete the existing symbolic link for your resolv.conf file:
sudo rm /etc/resolv.conf
- Create a new symbolic link pointing to the direct upstream configuration:
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
- Finally, restart the systemd-resolved service to apply the changes and free up port 53:
sudo systemctl restart systemd-resolved
You can now safely install Pi-hole, BIND9, or Dnsmasq without encountering any port conflicts.