Executing sudo apt update, cloning a repository with git, or fetching a web payload with curl on an Ubuntu system only to receive the error “Could not resolve host: archive.ubuntu.com” or “Temporary failure in name resolution” means your Linux system cannot translate domain names into IP addresses. In modern Ubuntu releases (including 22.04 LTS and 24.04 LTS), DNS resolution is managed by systemd-resolved via a stub listener. When the symbolic link to /etc/resolv.conf breaks, DNS caching daemons freeze, or upstream gateway DNS servers fail, all network applications lose name resolution.
Verify and Restart systemd-resolved
The systemd-resolved daemon provides network name resolution to local applications. If the service enters an inactive or crashed state, applications fail to resolve hostnames.
- Open a Terminal window (press Ctrl + Alt + T).
- Check the operational status of the resolver service:
systemctl status systemd-resolved - If the service is inactive or failed, start and enable it:
sudo systemctl enable --now systemd-resolved - Restart the service to flush stale query buffers:
sudo systemctl restart systemd-resolved - Test whether domain resolution is restored by pinging a public address:
ping -c 3 archive.ubuntu.com
Restore the Correct /etc/resolv.conf Symbolic Link
Third-party VPNs and network management tools frequently overwrite /etc/resolv.conf with static files, severing the link to systemd’s dynamic resolver stub.
- Inspect the current
/etc/resolv.conffile:ls -l /etc/resolv.conf - If the file is a regular file rather than a symbolic link pointing to
/run/systemd/resolve/stub-resolv.conf, remove it:sudo rm /etc/resolv.conf - Recreate the correct symbolic link:
sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf - Restart the resolver:
sudo systemctl restart systemd-resolved
Configure Fallback Public DNS Nameservers
If your local router or DHCP server supplies broken or unreachable DNS server addresses, configure global upstream nameservers directly inside systemd.
- Open the systemd-resolved configuration file:
sudo nano /etc/systemd/resolved.conf - Locate the line beginning with
#DNS=. Remove the leading hash (#) to uncomment it and specify Google or Cloudflare nameservers:DNS=8.8.8.8 1.1.1.1 - Locate the line
#FallbackDNS=, uncomment it, and enter:FallbackDNS=8.8.4.4 1.0.0.1 - Press Ctrl + O followed by Enter to save, then Ctrl + X to exit.
- Restart the service:
sudo systemctl restart systemd-resolved
Verify Operational DNS Status with resolvectl
Confirm that your active network interfaces are binding to upstream DNS servers.
- Execute the resolver query utility:
resolvectl status - Check the section for your active interface (e.g.
wlan0oreth0). - Ensure that Current DNS Server displays a valid IP address.
- Run
sudo apt updateto confirm that package repositories resolve cleanly without errors.