How to Fix ‘Temporary failure resolving’ DNS Errors in Ubuntu Linux

One of the most common and disruptive networking errors encountered on Ubuntu Linux workstations and servers is: "Temporary failure resolving 'archive.ubuntu.com'" or "Could not resolve host". When this error occurs, system updates via apt update fail, curl and wget commands cannot reach remote endpoints, and web browsers report that websites cannot be reached—despite an active network link or local router connection.

This failure indicates that the system’s Domain Name System (DNS) resolver cannot translate human-readable domain names into corresponding IP addresses. In Ubuntu, modern network configurations rely on systemd-resolved and a symbolic link to /etc/resolv.conf. A broken symlink, misconfigured static DNS addresses in Netplan, or a stalled local resolver daemon will instantly sever domain resolution. This guide details step-by-step diagnostic procedures and permanent remediation methods to restore DNS functionality.

Verifying the Underlying Network Connection

Before modifying DNS configuration files, confirm that your system maintains basic layer-3 network connectivity. Ping a known public IP address directly (bypassing DNS resolution):

ping -c 4 8.8.8.8
  • If ping succeeds: Your network interface is active and routing packets correctly. The issue is strictly isolated to the DNS resolution subsystem.
  • If ping returns “Network is unreachable”: The issue lies with your default gateway, DHCP lease, or physical/virtual network interface. Check your network link with ip route show or restart your connection before proceeding.

Method 1: Restarting and Inspecting systemd-resolved

Ubuntu 20.04, 22.04, and 24.04 LTS manage local DNS caching and stub resolution through systemd-resolved. If this daemon becomes unresponsive or out-of-sync with your router’s DHCP updates, restarting it often resolves the failure immediately.

  1. Check the active status of the service:
    systemctl status systemd-resolved
  2. If the service is stopped or in an error state, restart it:
    sudo systemctl restart systemd-resolved
  3. Ensure the service is configured to launch automatically on system boot:
    sudo systemctl enable systemd-resolved
  4. Flush the local DNS resolution cache:
    sudo resolvectl flush-caches
  5. Inspect the currently assigned upstream DNS servers:
    resolvectl status

    Ensure that active interfaces display valid DNS servers (e.g., your router IP 192.168.1.1 or public resolvers like 1.1.1.1).

Method 2: Rebuilding the /etc/resolv.conf Symlink

In Ubuntu, /etc/resolv.conf should never be a static file; it must exist as a symbolic link pointing to the dynamic stub configuration maintained by systemd-resolved. If an application, container engine, or manual edit replaced this symlink with a static file, DNS resolution will break whenever network leases change.

  1. Inspect the current status of the file:
    ls -l /etc/resolv.conf
  2. If the file is not a symbolic link pointing to ../run/systemd/resolve/stub-resolv.conf, remove the static or corrupted file:
    sudo rm -f /etc/resolv.conf
  3. Recreate the correct symbolic link:
    sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
  4. Restart systemd-resolved:
    sudo systemctl restart systemd-resolved

Method 3: Configuring Static Upstream DNS in systemd-resolved

If your local router’s DHCP server fails to provide reliable DNS addresses, you can configure fallback public DNS resolvers directly within the systemd-resolved configuration file.

  1. Open the configuration file in a terminal text editor:
    sudo nano /etc/systemd/resolved.conf
  2. Locate the [Resolve] section and uncomment or add the DNS= and FallbackDNS= directives with trusted resolvers (such as Cloudflare and Google DNS):
    [Resolve]
    DNS=1.1.1.1 8.8.8.8
    FallbackDNS=1.0.0.1 8.8.4.4
    Domains=~.
  3. Save the file by pressing Ctrl + O, then Enter, and exit with Ctrl + X.
  4. Restart the resolver daemon to apply changes:
    sudo systemctl restart systemd-resolved

Method 4: Configuring Permanent DNS in Netplan

On modern Ubuntu installations (especially Ubuntu Server), network interfaces are configured through Netplan YAML files located in /etc/netplan/. Setting nameservers in Netplan guarantees that your DNS configuration survives system reboots and DHCP renewals.

  1. List the files in the Netplan directory to identify your configuration filename:
    ls /etc/netplan/

    Typically, this file is named 01-netcfg.yaml, 50-cloud-init.yaml, or similar.

  2. Open the file for editing:
    sudo nano /etc/netplan/01-netcfg.yaml
  3. Locate your active network interface (e.g., eth0, enp3s0, or wlan0) and add the nameservers block under its configuration:
    network:
      version: 2
      renderer: networkd
      ethernets:
        enp3s0:
          dhcp4: true
          nameservers:
            addresses: [1.1.1.1, 8.8.8.8]
  4. Save and exit the file. Apply the Netplan configuration:
    sudo netplan apply

Testing and Validating DNS Resolution

Once you apply one of the remedies above, test domain name resolution using standard terminal diagnostics:

  1. Resolve an external domain with ping:
    ping -c 3 google.com
  2. Test package repository reachability:
    sudo apt update
  3. Perform a detailed lookup using dig or nslookup:
    resolvectl query archive.ubuntu.com

When the output returns valid IP addresses and apt update synchronises repositories without resolution warnings, your Ubuntu DNS resolver is completely restored and operating normally.

Get the best tech tips delivered straight to your inbox.

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