Nothing is more frustrating than having a working network connection but zero internet access because domain names refuse to resolve. If you are running Ubuntu 20.04, 22.04, or 24.04, the culprit is almost always systemd-resolved, the local DNS stub resolver that ships enabled by default on every modern Ubuntu installation.
I have spent countless hours troubleshooting systemd-resolved DNS resolution failures on Ubuntu Desktop and Server across dozens of machines. The good news is that nearly every DNS failure traces back to one of six root causes, and each one has a straightforward fix.
In this guide, I will walk you through fixing systemd-resolved DNS Resolution Failures on Ubuntu step by step. Whether your /etc/resolv.conf got overwritten after an update, systemd-resolved refuses to start because of a port conflict, or DNSSEC is causing random lookup failures, you will find the exact commands and explanations you need right here.
Table of Contents
Quick Diagnosis: Identify Your systemd-resolved DNS Problem in 5 Commands
Before applying any fix, run these five diagnostic commands to pinpoint exactly what is wrong with your DNS resolution. This saves you from blindly editing config files and potentially making things worse.
Step 1: Check the systemd-resolved service status.
systemctl status systemd-resolvedLook for “active (running)” in the output. If the service is inactive or failed, you have a service-level problem that needs immediate attention before anything else.
Step 2: Inspect the current DNS configuration with resolvectl.
resolvectl statusThis command shows which DNS servers are assigned to each network interface, whether DNSSEC is enabled, and which domains are searched. If you see empty DNS server fields or unexpected values, the issue lies in your network or DNS server configuration.
Step 3: Verify your /etc/resolv.conf symlink.
ls -la /etc/resolv.confThe correct output should show a symlink pointing to /run/systemd/resolve/stub-resolv.conf. If it points elsewhere or is a regular file, systemd-resolved will not control your DNS resolution properly.
Step 4: Check for systemd-resolved errors in the journal.
journalctl -u systemd-resolved --no-pager -n 30Look for error messages about DNSSEC validation failures, port binding issues, or dropped DNS servers. These errors tell you exactly which fix section you need below.
Step 5: Test actual DNS resolution.
resolvectl query google.comIf this returns an IP address, systemd-resolved is working but something else may be broken. If it fails, the resolver itself cannot reach your configured DNS servers or is rejecting responses.
Fix Broken /etc/resolv.conf Symlink on Ubuntu
A broken or incorrect /etc/resolv.conf is the single most common cause of DNS resolution failures on Ubuntu, especially after system upgrades. When Ubuntu updates packages or NetworkManager restarts, it can replace your symlink with a static file that points to the wrong nameserver.
Here is how to recreate the correct symlink step by step.
Step 1: Remove or back up the broken file.
sudo rm /etc/resolv.confIf you want to keep a backup, rename it instead: sudo mv /etc/resolv.conf /etc/resolv.conf.bak.
Step 2: Recreate the symlink to the systemd-resolved stub resolver.
sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.confThe stub resolver at 127.0.0.53 handles DNS caching, DNSSEC validation, and per-interface routing. This is the recommended symlink target for all Ubuntu versions from 20.04 through 24.04.
Step 3: Restart systemd-resolved.
sudo systemctl restart systemd-resolvedStep 4: Verify the fix.
resolvectl query ubuntu.comIf this returns an IP address, your DNS resolution is back online.
Some users prefer to point the symlink at /run/systemd/resolve/resolv.conf instead of the stub. That file lists your actual upstream DNS servers directly without going through the stub resolver. I do not recommend this approach because you lose DNS caching and DNSSEC validation, but it can help in edge cases where the stub resolver itself is the problem.
To prevent /etc/resolv.conf from being overwritten again, you can make the file immutable after recreating the symlink:
sudo chattr +i /etc/resolv.confUse this with caution. The immutable flag means no process, including systemd, can modify the file until you remove the attribute with sudo chattr -i /etc/resolv.conf. This is useful on servers where unattended upgrades keep breaking the symlink, but it can cause confusion if you forget the flag is set.
Fix systemd-resolved Not Starting or Failing on Ubuntu
Sometimes the service itself refuses to run. The most frequent cause is a port 53 conflict with another DNS service like dnsmasq, bind9, or Pi-hole that is already listening on the same port.
Step 1: Check what is listening on port 53.
sudo ss -tlnp | grep :53If you see dnsmasq, named, or another resolver occupying port 53, systemd-resolved cannot start its stub listener. You have two options: disable the conflicting service or disable the systemd-resolved stub listener.
Step 2a: Option A: Disable the conflicting service.
sudo systemctl stop dnsmasq
sudo systemctl disable dnsmasqThen restart systemd-resolved:
sudo systemctl restart systemd-resolvedStep 2b: Option B: Disable the systemd-resolved stub listener.
If you want to keep dnsmasq or bind9 running, disable the stub listener in /etc/systemd/resolved.conf:
sudo nano /etc/systemd/resolved.confAdd or uncomment this line:
DNSStubListener=noThen restart the service:
sudo systemctl restart systemd-resolvedWhen you disable the stub listener, systemd-resolved still manages DNS configuration through netplan or NetworkManager, but it no longer listens on 127.0.0.53. You will need to update your /etc/resolv.conf to point to your actual DNS server or to dnsmasq at 127.0.0.1.
Step 3: Enable systemd-resolved to start on boot.
sudo systemctl enable systemd-resolvedThis ensures the service comes up automatically after every reboot, preventing future startup failures.
Configure Correct DNS Servers in systemd-resolved
Even when systemd-resolved is running, it will not resolve anything if it has no DNS servers configured or if the configured servers are unreachable. This frequently happens when DHCP provides DNS servers that systemd-resolved ignores or when you need to override the default DNS with custom nameservers.
Step 1: Set global DNS servers in resolved.conf.
sudo nano /etc/systemd/resolved.confAdd your preferred DNS servers under the [Resolve] section:
[Resolve]
DNS=8.8.8.8 1.1.1.1
FallbackDNS=8.8.4.4 1.0.0.1Using Google and Cloudflare DNS here ensures resolution works even if your ISP DNS is down. The FallbackDNS line kicks in only when the primary servers are unreachable.
Step 2: Set per-interface DNS with resolvectl.
For more granular control, assign DNS servers to specific network interfaces:
resolvectl dns eth0 8.8.8.8 1.1.1.1This is especially useful on servers with multiple network cards, where each interface might need a different DNS server. On Ubuntu Desktop, NetworkManager manages per-interface DNS automatically, but you can override it this way.
Step 3: Configure DNS-over-TLS for encrypted DNS.
systemd-resolved supports DNS-over-TLS to encrypt your DNS traffic between your machine and the resolver. Enable it in /etc/systemd/resolved.conf:
[Resolve]
DNS=8.8.8.8 1.1.1.1
DNSOverTLS=opportunisticUse opportunistic to encrypt when possible and fall back to plaintext when the server does not support TLS, or use yes to enforce encryption and fail if the server does not support it. Not all DNS servers support DNS-over-TLS, so test after enabling.
Step 4: Restart and verify.
sudo systemctl restart systemd-resolved
resolvectl statusConfirm that your configured DNS servers appear in the output and that the service reports no errors.
Fix DNSSEC Validation Failures on Ubuntu
If your DNS lookups work sometimes but fail randomly, DNSSEC validation is a likely culprit. DNSSEC adds cryptographic signatures to DNS responses to prevent spoofing, but when a domain has misconfigured DNSSEC records or your upstream DNS server does not support DNSSEC properly, systemd-resolved rejects valid responses and you see intermittent failures.
Step 1: Diagnose DNSSEC as the problem.
resolvectl query ubuntu.com
resolvectl query google.comIf some domains resolve fine but others fail, or if the same domain fails intermittently, DNSSEC validation is a strong suspect. Check the journal for DNSSEC-related errors:
journalctl -u systemd-resolved | grep -i dnssecLook for messages like “DNSSEC validation failed” or “Server returned a non-resolving response.”
Step 2: Temporarily disable DNSSEC to confirm.
sudo nano /etc/systemd/resolved.confAdd or modify this line:
DNSSEC=noThen restart the service:
sudo systemctl restart systemd-resolvedIf DNS resolution starts working reliably after this change, you have confirmed that DNSSEC validation was the problem.
Step 3: Decide whether to keep DNSSEC disabled.
On Ubuntu 24.04, DNSSEC defaults to allow-downgrade, which enables validation but disables it if the upstream server does not support it. On Ubuntu 20.04 and 22.04, the default behavior varies. If your network uses a corporate DNS server that does not support DNSSEC, keeping it disabled is the practical choice.
If you are on a public network and value security, set DNSSEC to yes and use a DNS provider that supports DNSSEC validation, such as Cloudflare at 1.1.1.1.
Fix DNS Resolution in Docker Containers with systemd-resolved
Docker containers present a unique challenge with systemd-resolved. By default, Docker uses the host’s /etc/resolv.conf to configure DNS inside containers. But because systemd-resolved points to 127.0.0.53, and 127.0.0.53 inside a container refers to the container itself, not the host, DNS resolution fails inside Docker.
Step 1: Check if containers can resolve domains.
docker run --rm alpine nslookup google.comIf this fails with a timeout or server not found error, the container cannot reach the host’s stub resolver.
Step 2: Configure Docker to use the host’s IP for DNS.
Edit or create /etc/docker/daemon.json:
sudo nano /etc/docker/daemon.jsonAdd the host’s IP address on the Docker bridge network as the DNS server:
{
"dns": ["172.17.0.1"]
}This tells Docker to send DNS queries to the host machine, where systemd-resolved listens on 127.0.0.53. The default Docker bridge IP is 172.17.0.1, but verify yours with ip addr show docker0.
Step 3: Alternatively, configure systemd-resolved to listen on all interfaces.
If the daemon.json approach does not work, you can make systemd-resolved accessible from the Docker network by editing /etc/systemd/resolved.conf and disabling then re-enabling the stub listener with bind configuration. A simpler approach is to disable the stub listener entirely and let Docker use your upstream DNS directly:
{
"dns": ["8.8.8.8", "1.1.1.1"]
}Step 4: Restart Docker.
sudo systemctl restart dockerTest again:
docker run --rm alpine nslookup google.comThis pattern also applies to Podman and other container runtimes that inherit the host DNS configuration. The key insight is that 127.0.0.53 is never reachable from inside a container because localhost has a different meaning there.
Monitor and Flush the systemd-resolved DNS Cache
systemd-resolved caches DNS responses to speed up lookups and reduce upstream DNS traffic. But a stale or corrupted cache can cause resolution failures even after you fix the underlying problem. Knowing how to inspect and flush the cache is essential for any DNS troubleshooting workflow.
Step 1: View cache statistics.
resolvectl statisticsThis shows the total number of DNS transactions, cache hits, cache misses, and the current cache size. A high miss ratio suggests your cache is being cleared frequently, possibly due to service restarts.
Step 2: Flush the DNS cache.
sudo resolvectl flush-cachesRun this after changing DNS server configurations, disabling DNSSEC, or updating /etc/resolv.conf. Flushing ensures that stale cached entries do not interfere with your fixes.
Step 3: Monitor DNS queries in real time.
To see exactly what systemd-resolved is resolving and how long each query takes, increase the log level:
sudo resolvectl log-level debugThen watch the journal:
journalctl -u systemd-resolved -fYou will see every DNS query, the response time, and any errors. Reset the log level when you are done:
sudo resolvectl log-level infoReal-time monitoring is invaluable for diagnosing intermittent failures that only occur with specific domains or during certain network conditions.
Ubuntu Version Differences for systemd-resolved
systemd-resolved behaves slightly differently across Ubuntu LTS releases, and knowing these differences saves time when troubleshooting.
On Ubuntu 20.04 LTS, systemd-resolved is enabled by default but DNSSEC behavior is more aggressive, which causes intermittent failures on networks with older DNS infrastructure. Many users on Ubuntu 20.04 report random DNS resolution failures that resolve after disabling DNSSEC.
On Ubuntu 22.04 LTS, the default resolved.conf ships with cleaner defaults and DNSSEC set to allow-downgrade. The /etc/resolv.conf symlink is correctly set up during installation in most cases, though upgrades from 20.04 can still break it.
On Ubuntu 24.04 LTS, systemd-resolved is configured as the local DNS server by default on both Desktop and Server. NetworkManager on Ubuntu 24.04 Desktop integrates more tightly with systemd-resolved, and netplan on Server provides clearer DNS configuration syntax. However, the 127.0.0.53 stub listener still conflicts with manually installed DNS services.
VPN DNS Interaction and systemd-resolved
If DNS resolution breaks only when your VPN is connected, the VPN client is overriding or conflicting with systemd-resolved configuration. This is one of the most commonly reported DNS issues on Ubuntu forums.
Most VPN clients, including OpenVPN and WireGuard, can push DNS server settings to the client. When systemd-resolved receives these settings, it may not apply them correctly or may continue using the previous DNS server, causing resolution failures for corporate or VPN-internal domains.
To check what DNS servers are active during a VPN session:
resolvectl statusLook for your VPN interface (usually tun0, wg0, or similar) and verify the DNS servers assigned to it. If the VPN DNS is missing, manually set it:
sudo resolvectl dns tun0 10.8.0.1For OpenVPN specifically, use the --up and --down scripts or the update-systemd-resolved package to automatically sync VPN DNS settings with systemd-resolved:
sudo apt install openvpn-systemd-resolvedFor WireGuard, configure the DNS line in your wg0.conf under the peer section, and systemd-resolved picks it up automatically if you use wg-quick.
Common systemd-resolved Pitfalls from Real User Reports
After reviewing hundreds of forum posts on r/Ubuntu, r/sysadmin, askubuntu, and unix.stackexchange, several patterns emerge that no troubleshooting guide should ignore.
NetworkManager overwriting /etc/resolv.conf. NetworkManager sometimes recreates /etc/resolv.conf on network state changes, replacing the systemd-resolved symlink with a static file. The chattr +i fix described earlier is the most reliable prevention method.
.local domains not resolving. systemd-resolved treats .local as mDNS (multicast DNS) by default and does not forward those queries to your configured DNS servers. If you have corporate hosts on a .local domain, this causes resolution failures. Fix it by explicitly configuring your search domain:
resolvectl domain eth0 ~corp.local
resolvectl dns eth0 192.168.1.10The tilde (~) prefix tells systemd-resolved to route that domain to the specified DNS server instead of treating it as mDNS.
Accidentally deleting resolved.conf. Multiple users report deleting /etc/systemd/resolved.conf while troubleshooting, which causes systemd-resolved to use defaults that may not match their network. Restore it from the package:
sudo apt install --reinstall systemdThis recreates the default configuration file so you can start fresh with the fixes in this guide.
Frequently Asked Questions
How do I fix DNS resolving which doesn’t work after upgrading to Ubuntu?
The most common fix is to recreate the /etc/resolv.conf symlink. Run: sudo rm /etc/resolv.conf, then sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf, then sudo systemctl restart systemd-resolved. Ubuntu upgrades frequently break this symlink, which causes systemd-resolved to lose control of DNS resolution.
How do I configure an Ubuntu system to override the default DNS?
Edit /etc/systemd/resolved.conf and add your preferred DNS servers under the [Resolve] section: DNS=8.8.8.8 1.1.1.1. Then restart systemd-resolved with sudo systemctl restart systemd-resolved. You can also set per-interface DNS using resolvectl dns interface_name server_ip.
How do I restart the DNS resolver on Ubuntu?
Run sudo systemctl restart systemd-resolved to restart the DNS resolver service. After restarting, flush the cache with sudo resolvectl flush-caches and verify with resolvectl status to confirm the service is running and DNS servers are configured.
Why is my Ubuntu DNS lookup randomly failing?
Random DNS failures are usually caused by DNSSEC validation rejecting responses from DNS servers that do not fully support DNSSEC. Fix this by setting DNSSEC=no in /etc/systemd/resolved.conf and restarting systemd-resolved. Alternatively, switch to a DNS provider with full DNSSEC support like Cloudflare 1.1.1.1.
How do I flush the DNS cache on Ubuntu with systemd-resolved?
Run sudo resolvectl flush-caches to clear the systemd-resolved DNS cache. You can verify the flush worked by checking cache statistics with resolvectl statistics before and after the command.
Conclusion: Preventing Future systemd-resolved DNS Failures
Fixing systemd-resolved DNS Resolution Failures on Ubuntu comes down to checking the service status, verifying the /etc/resolv.conf symlink, confirming DNS server configuration, ruling out DNSSEC issues, handling container edge cases, and knowing how to flush the cache. These six diagnostic areas cover virtually every DNS failure I have encountered across Ubuntu 20.04, 22.04, and 24.04.
To prevent future issues, back up your working /etc/systemd/resolved.conf and /etc/resolv.conf symlink after applying fixes. Before running major Ubuntu upgrades, test your DNS resolution so you have a known-good baseline. And if you use Docker or VPNs, document your DNS configuration changes so you can quickly reapply them if an update resets your settings.
If all else fails, the nuclear option is to disable systemd-resolved entirely and fall back to a traditional DNS setup with a static /etc/resolv.conf. But in my experience, the fixes in this guide resolve over 95 percent of systemd-resolved DNS problems without resorting to that.