Error Codes Wiki

Linux DNS Resolution Failures — resolv.conf, systemd-resolved & nsswitch

Warningnetwork

Overview

Fix Linux DNS resolution failures including 'Temporary failure in name resolution', systemd-resolved issues, resolv.conf overwriting, and nsswitch.conf misconfiguration.

Key Details

  • /etc/resolv.conf specifies DNS servers — may be managed by systemd-resolved, NetworkManager, or resolvconf
  • systemd-resolved provides a local DNS stub at 127.0.0.53 — resolv.conf should point to this
  • /etc/nsswitch.conf controls name resolution order (files, dns, mdns, etc.)
  • Docker containers use their own /etc/resolv.conf — 127.0.0.53 does not work inside containers
  • VPN software often modifies resolv.conf, breaking DNS when disconnected

Common Causes

  • Empty or incorrect /etc/resolv.conf (no nameserver entries)
  • systemd-resolved service not running
  • NetworkManager or DHCP client overwriting manual resolv.conf changes
  • Docker container unable to reach 127.0.0.53 (host-only stub resolver)
  • VPN modified resolv.conf and did not restore it on disconnect

Steps

  1. 1Check current DNS: cat /etc/resolv.conf — should have nameserver entries
  2. 2Test resolution: nslookup google.com or dig google.com
  3. 3Restart systemd-resolved: sudo systemctl restart systemd-resolved
  4. 4Set manual DNS: echo 'nameserver 8.8.8.8' | sudo tee /etc/resolv.conf
  5. 5For persistent config: edit /etc/systemd/resolved.conf and set DNS=8.8.8.8 1.1.1.1, then restart resolved

Tags

linuxdnsresolv.confsystemd-resolvedname-resolution

More in Network

Frequently Asked Questions

NetworkManager, DHCP, or systemd-resolved manages it. For systemd-resolved: edit /etc/systemd/resolved.conf instead. For NM: set DNS in the connection profile.