How to Fix ‘Temporary Failure in Name Resolution’ in Ubuntu

Attempting to install an APT package, update software repositories, or ping an external web address in Ubuntu Terminal only to be blocked by the error: “Temporary failure in name resolution” or “Could not resolve host: archive.ubuntu.com” halts all network operations. In Linux operating systems, name resolution is the process handled by Domain Name System (DNS) resolver libraries that translate human-readable domain names (such as ubuntu.com) into machine-routable IP addresses. When the local DNS caching daemon (systemd-resolved) fails, the /etc/resolv.conf symlink becomes broken, or your upstream router DNS servers stop answering lookup queries, the system loses the ability to resolve external network paths. This step-by-step troubleshooting guide details diagnostic procedures to identify DNS lookup failures, repair systemd-resolved, and configure reliable nameservers in Ubuntu.

Common Causes Behind Linux Name Resolution Failures

Pinpointing whether the failure originates from local configuration symlinks, the local systemd daemon, or external gateway DNS routing ensures swift resolution. Review the common points of failure below.

Failure Point Observable Indicator Primary Diagnostic Step
Broken /etc/resolv.conf Symlink File is missing, empty, or points to a non-existent stub resolver path. Re-link /etc/resolv.conf to systemd-resolved’s dynamic stub file.
Halted systemd-resolved Daemon Local DNS listener at 127.0.0.53:53 is inactive or crashed. Restart and enable the systemd-resolved service unit.
Unresponsive Router DNS Gateway Pinging numeric IPs (e.g. 8.8.8.8) succeeds, but pinging domain names fails. Configure public fallback nameservers (Cloudflare 1.1.1.1 / Google 8.8.8.8).
Netplan YAML Syntax Misconfiguration DNS entries omitted or improperly indented under network adapter profiles. Add explicit nameservers to Netplan configuration and execute netplan apply.
VPN / Tailscale DNS Hijacking Resolution fails immediately after disconnecting from a commercial VPN or overlay network. Reset DNS routing tables and clear stale network manager connections.

Step 1: Test Connectivity via Raw IP Addresses (Isolate DNS from Network)

Before modifying DNS configuration files, confirm whether your Ubuntu machine has an active physical network connection. Pinging a raw numeric IP address verifies if internet routing is functional.

  1. Open your Terminal window (press Ctrl + Alt + T).
  2. Ping Cloudflare’s public DNS IP address:
    ping -c 3 1.1.1.1
  3. If the ping returns “3 packets transmitted, 3 received, 0% packet loss”, your physical network and internet gateway are operating perfectly, confirming that the failure is purely confined to DNS name resolution.
  4. If pinging 1.1.1.1 returns “Network is unreachable”, your issue is a physical network disconnection, missing default gateway, or Wi-Fi authentication error.

Step 2: Restart and Verify the systemd-resolved Daemon

Modern Ubuntu installations (including Ubuntu 20.04, 22.04 LTS, and 24.04 LTS) rely on systemd-resolved to manage local DNS caching and upstream nameserver queries.

  1. Check the operational status of the resolver service:
    sudo systemctl status systemd-resolved
  2. If the service is inactive, dead, or in a degraded state, restart and enable it:
    sudo systemctl restart systemd-resolved
    sudo systemctl enable systemd-resolved
  3. Inspect active DNS servers recognized by the system:
    resolvectl status
  4. Verify that your active network interface (such as eth0 or wlan0) lists at least one valid DNS server under the DNS Servers line.

Step 3: Recreate the /etc/resolv.conf Symlink

The standard Linux resolver library reads configuration from /etc/resolv.conf. In Ubuntu, this file must not be a static text file; it must be a dynamic symbolic link pointing to systemd-resolved’s internal stub file. Third-party software or manual edits frequently break this link.

  1. Check if /etc/resolv.conf is a valid symlink:
    ls -l /etc/resolv.conf
  2. If it is a regular static file or broken pointer, remove it:
    sudo rm -f /etc/resolv.conf
  3. Recreate the authentic symbolic link to the systemd-resolved stub:
    sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
  4. Restart the service:
    sudo systemctl restart systemd-resolved
  5. Test name resolution by pinging a domain:
    ping -c 3 ubuntu.com

Step 4: Configure Static Upstream Nameservers via Netplan

If your local router’s DHCP server fails to provide responsive DNS servers, configure high-performance public DNS nameservers (such as Cloudflare and Google) directly in Ubuntu’s Netplan configuration.

  1. Navigate to the Netplan directory:
    cd /etc/netplan
    ls
  2. Open your active YAML configuration file (e.g. 01-netcfg.yaml or 50-cloud-init.yaml) in the Nano text editor:
    sudo nano /etc/netplan/01-netcfg.yaml
  3. Under your active interface (e.g. ethernets: eth0:), add or update the nameservers block using strict two-space indentation:
          nameservers:
            addresses: [1.1.1.1, 8.8.8.8, 1.0.0.1]
  4. Save the file by pressing Ctrl + O and exit with Ctrl + X.
  5. Apply the updated network configuration:
    sudo netplan apply
  6. Your Ubuntu system will now route all DNS queries directly to resilient public resolvers, permanently resolving name resolution timeouts.

Get the best tech tips delivered straight to your inbox.

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