Temporary failure in name resolution

Fix systemd-resolved DNS failure on Linux

Linux & Unix Beginner 👁 23 views 📅 Jun 23, 2026

DNS stops resolving after systemd-resolved fails. We'll fix it by checking the stub resolver and DNS config.

Quick answer

Run sudo resolvectl flush-caches then sudo systemctl restart systemd-resolved. If still broken, check /etc/resolv.conf points to 127.0.0.53.

Why this happens

systemd-resolved manages DNS on modern Linux distros — Ubuntu 18.04+, Fedora 31+, Debian 10+. It acts as a local stub resolver on 127.0.0.53:53. When it fails, you get "Temporary failure in name resolution" in ping, curl, or apt. I've seen this after a VPN disconnects, a network restart during a system update, or when NetworkManager overwrites the stub resolver config. The fix is usually quick, but the error feels like your machine went offline completely. It hasn't — just the resolver got confused.

Fix steps

  1. Check if systemd-resolved is running
    systemctl status systemd-resolved
    If it shows inactive (dead), start it: sudo systemctl start systemd-resolved.
  2. Flush the DNS cache
    sudo resolvectl flush-caches
    This clears any stale entries that might be causing the temporary failure. I do this every time before anything else.
  3. Verify /etc/resolv.conf
    Run ls -l /etc/resolv.conf. It should be a symlink to /run/systemd/resolve/stub-resolv.conf. If it's a regular file or points somewhere else, run:
    sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
  4. Check the stub resolver
    resolvectl status — look for DNS Servers: 127.0.0.53 under your interface. If you see 0.0.0.0 or nothing, the stub resolver isn't configured. Fix it with:
    sudo resolvectl dns eth0 1.1.1.1 (replace eth0 with your interface name from ip link).
  5. Restart the service
    sudo systemctl restart systemd-resolved
    Then test: ping google.com. Should work now.

Alternative fixes

NetworkManager conflict

If you use NetworkManager, it might set its own DNS servers and ignore systemd-resolved. Edit /etc/NetworkManager/NetworkManager.conf and add under [main]:
dns=systemd-resolved
Then restart: sudo systemctl restart NetworkManager. I've seen this fix 50% of cases on Ubuntu 22.04.

Fallback to Google DNS

If systemd-resolved keeps failing, you can skip it entirely. Edit /etc/systemd/resolved.conf and set:
[Resolve]
DNS=8.8.8.8 8.8.4.4
FallbackDNS=1.1.1.1

Then sudo systemctl restart systemd-resolved. This bypasses the stub resolver and uses upstream DNS directly. Works, but you lose local network name resolution (like .local domains).

Disable and use /etc/resolv.conf

Last resort: stop systemd-resolved and use plain /etc/resolv.conf.
sudo systemctl disable --now systemd-resolved
sudo rm /etc/resolv.conf
echo 'nameserver 8.8.8.8' | sudo tee /etc/resolv.conf
I don't love this because you lose systemd-resolved's caching and DNSSEC, but it works every time.

Prevention tip

To stop this from happening again, make sure your DNS configuration is consistent. If you use a VPN client (like OpenVPN or WireGuard), check that it doesn't override /etc/resolv.conf directly — use update-resolv-conf scripts that work with systemd-resolved. Also, avoid manually editing /etc/resolv.conf while systemd-resolved is active — it's managed by symlinks. I set a cron job to check the symlink once a week:
0 3 * * 1 test -L /etc/resolv.conf || ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

Was this solution helpful?