How to Completely Disable the ‘systemd-resolved’ DNS Stub Listener in Ubuntu

Modern Ubuntu installations handle DNS (Domain Name System) lookups through a background service known as systemd-resolved. To help cache requests and improve browsing speed, this service creates a local “stub listener.” It binds itself to 127.0.0.53 on port 53 and forces all local network traffic to route through it before reaching out to the internet.

While this is completely invisible to standard desktop users, it is a massive headache for homelab enthusiasts and system administrators. If you attempt to install a custom DNS server, such as Pi-hole, AdGuard Home, or BIND9 on your Ubuntu machine, the installation will instantly fail with a “Port 53 is already in use” error. Because systemd-resolved is stubbornly hogging the DNS port, your custom software cannot listen for incoming queries. To fix this, you must completely disable the stub listener.

Disabling the Stub Listener via Systemd Config

You cannot simply kill the systemd-resolved service, as it breaks Ubuntu’s ability to resolve internet addresses entirely. Instead, you must instruct the service to stop listening on port 53.

  1. Open a Terminal session (or connect via SSH).
  2. Open the resolved configuration file in a text editor (like nano) with root privileges:
    sudo nano /etc/systemd/resolved.conf
  3. Look down the file for the line that says #DNSStubListener=yes. (The hash # means it is currently commented out and using the default ‘yes’ setting).
  4. Remove the hash # to uncomment the line.
  5. Change yes to no. The line should now look exactly like this:
    DNSStubListener=no
  6. Save the file (Ctrl + O, then Enter) and exit the editor (Ctrl + X).

Creating a New resolv.conf Symlink

Because you disabled the stub listener, Ubuntu no longer knows where to send DNS requests. You must delete the old symlink that pointed to the local stub and replace it with one that points to the actual DNS servers provided by your router.

  1. In the terminal, delete the existing symlink:
    sudo rm /etc/resolv.conf
  2. Create a new symlink pointing to the global systemd configuration:
    sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
  3. Finally, restart the systemd-resolved service to apply all your changes:
    sudo systemctl restart systemd-resolved

The change is instantaneous. The stub listener is completely dead, and port 53 is now wide open and available. You can safely install Pi-hole or any other DNS software without encountering binding errors.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.