Booting up an Ubuntu desktop or server only to notice a red failure line in your systemd startup log stating “Failed to start Network Name Resolution” (or discovering that systemd-resolved.service has entered a failed state) triggers an immediate total internet outage. While your network card may possess a valid IP address and ping gateway IPs successfully, web browsers display “Server not found”, and executing sudo apt update terminates with “Temporary failure in name resolution”.
The systemd-resolved daemon is Ubuntu’s native network name resolution manager, listening on local loopback address 127.0.0.53:53 to handle DNS lookups for all system applications. When this service fails to start, the failure is almost universally caused by broken symbolic links in /etc/resolv.conf, port 53 socket conflicts with third-party DNS software (such as dnsmasq, Pi-hole, or BIND9), or syntax errors in /etc/systemd/resolved.conf. This tutorial walks you through practical terminal commands to repair systemd-resolved and restore DNS resolution.
Method 1: Inspect Service Failure Logs via journalctl
Before modifying network configuration files, query the systemd journal to discover the exact reason systemd-resolved refused to start.
- Open your terminal by pressing Ctrl + Alt + T (or log in via local console).
- Inspect the status of the name resolution service:
systemctl status systemd-resolved.service - Query the systemd journal for specific failure logs:
journalctl -u systemd-resolved.service -b --no-pager - Look for error indicators such as:
- “Failed to bind UDP socket to 127.0.0.53:53: Address already in use” (Port 53 conflict).
- “Failed to parse config file” (Syntax error in resolved.conf).
Method 2: Recreate the Canonical /etc/resolv.conf Symlink
In Ubuntu, /etc/resolv.conf must never be a static text file; it must be a symbolic link pointing to systemd-resolved’s dynamic stub resolver file. If third-party software overwrote this symlink with a static file, name resolution fails.
- Check if
/etc/resolv.confis a symlink or a regular file:ls -la /etc/resolv.conf - If the output does not show
/etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf, remove the static or corrupted file:sudo rm -f /etc/resolv.conf - Recreate the proper symbolic link:
sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf - Restart the service:
sudo systemctl restart systemd-resolved - Test DNS resolution by pinging a domain:
ping -c 3 ubuntu.com
Method 3: Resolve Port 53 Socket Conflicts (dnsmasq / Docker)
If another application—such as a local caching DNS forwarder, Pi-hole, dnsmasq, or a Docker container—is already listening on port 53, systemd-resolved cannot bind its stub listener.
- Identify which process is holding port 53:
sudo ss -tulpn | grep ':53 ' - If a process such as
dnsmasqornamedis listed, determine whether that service is required. If unintended, stop and disable it:sudo systemctl stop dnsmasq && sudo systemctl disable dnsmasq - Alternatively, if you must run a custom DNS server locally, configure systemd-resolved to disable its local stub listener:
sudo nano /etc/systemd/resolved.conf - Under the
[Resolve]heading, set:DNSStubListener=no - Save the file (Ctrl + O, then Ctrl + X) and restart the service:
sudo systemctl restart systemd-resolved
Method 4: Specify Static Fallback DNS Servers in resolved.conf
If your router DHCP fails to supply valid upstream DNS nameservers, configure systemd-resolved with trusted public DNS fallback servers.
- Open the systemd-resolved configuration in nano:
sudo nano /etc/systemd/resolved.conf - Uncomment and update the DNS and FallbackDNS directives:
[Resolve] DNS=1.1.1.1 8.8.8.8 FallbackDNS=1.0.0.1 8.8.4.4 - Save and exit nano.
- Enable and restart the service cleanly:
sudo systemctl enable --now systemd-resolved - Verify that DNS queries resolve:
resolvectl status
Ubuntu systemd-resolved Troubleshooting Reference Table
Use the matrix below to assess resolution failure modes and their proven solutions:
| Observed Failure State | Underlying Root Cause | Standard Resolution Command |
|---|---|---|
| “Failed to bind UDP socket: Address in use” | Another service (dnsmasq/named) bound to port 53 | sudo ss -tulpn | grep :53 & disable conflicting service |
| /etc/resolv.conf is a broken link | Missing /run/systemd/resolve/stub-resolv.conf | sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf |
| resolvectl status shows zero DNS servers | DHCP client failed to advertise DNS from router | Define static DNS=1.1.1.1 in /etc/systemd/resolved.conf |
| Temporary failure in name resolution on boot | Network online target triggered before resolved | sudo systemctl enable systemd-resolved |
| Ping IP works, ping domain name fails | Stalled DNS query cache in systemd-resolved | sudo resolvectl flush-caches |
Flushing the Systemd DNS Cache
Once systemd-resolved is active, cached negative DNS responses can cause applications to continue reporting “Temporary failure in name resolution” for several minutes. Flush the local cache immediately by executing: sudo resolvectl flush-caches. Verify cache statistics by running resolvectl statistics to ensure the cache has been reset to zero.