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 showor 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.
- Check the active status of the service:
systemctl status systemd-resolved - If the service is stopped or in an error state, restart it:
sudo systemctl restart systemd-resolved - Ensure the service is configured to launch automatically on system boot:
sudo systemctl enable systemd-resolved - Flush the local DNS resolution cache:
sudo resolvectl flush-caches - Inspect the currently assigned upstream DNS servers:
resolvectl statusEnsure that active interfaces display valid DNS servers (e.g., your router IP
192.168.1.1or public resolvers like1.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.
- Inspect the current status of the file:
ls -l /etc/resolv.conf - 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 - Recreate the correct symbolic link:
sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf - 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.
- Open the configuration file in a terminal text editor:
sudo nano /etc/systemd/resolved.conf - Locate the
[Resolve]section and uncomment or add theDNS=andFallbackDNS=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=~. - Save the file by pressing Ctrl + O, then Enter, and exit with Ctrl + X.
- 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.
- 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. - Open the file for editing:
sudo nano /etc/netplan/01-netcfg.yaml - Locate your active network interface (e.g.,
eth0,enp3s0, orwlan0) and add thenameserversblock under its configuration:network: version: 2 renderer: networkd ethernets: enp3s0: dhcp4: true nameservers: addresses: [1.1.1.1, 8.8.8.8] - 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:
- Resolve an external domain with
ping:ping -c 3 google.com - Test package repository reachability:
sudo apt update - Perform a detailed lookup using
digornslookup: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.