DNS Resolution Error
Linux Linux
Severity: ModerateWhat Does This Error Mean?
A DNS resolution error on Linux means your system cannot convert website names (like google.com) into IP addresses. You might see 'Name or service not known,' 'Could not resolve host,' or 'Temporary failure in name resolution.' Your internet connection itself may be working fine — only the name lookup is broken.
Affected Models
- Ubuntu
- Debian
- Fedora
- CentOS
- Arch Linux
- Linux Mint
- openSUSE
Common Causes
- The /etc/resolv.conf file is missing, empty, or pointing to an unreachable DNS server
- systemd-resolved is not running or has crashed
- A VPN client changed your DNS settings and did not restore them when disconnected
- Your router's DNS server is not working and your Linux system is using it
- NetworkManager changed DNS settings after a network reconnection
How to Fix It
-
Test if DNS is the problem. Run: ping 8.8.8.8 (an IP address, no DNS needed). If this works but ping google.com fails, DNS is definitely the issue.
Pinging an IP address bypasses DNS entirely. If IP pinging works, your internet connection is fine but name lookup is broken.
-
Try a manual DNS lookup. Run: nslookup google.com 8.8.8.8 to test DNS using Google's server. If this works, your regular DNS server is the problem.
If nslookup with 8.8.8.8 works, you can use Google's DNS (8.8.8.8) as a temporary fix while you investigate your regular DNS server.
-
Check and fix /etc/resolv.conf. Run: cat /etc/resolv.conf to see the current DNS servers. If the file is empty or missing, create it: echo 'nameserver 8.8.8.8' | sudo tee /etc/resolv.conf
On Ubuntu with systemd-resolved, /etc/resolv.conf is a symlink. If the symlink is broken, run: sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
-
Restart systemd-resolved. Run: sudo systemctl restart systemd-resolved. Then: sudo systemd-resolve --flush-caches to clear the DNS cache.
systemd-resolved is the DNS resolver on most Ubuntu and modern Debian systems. Restarting it clears cached bad results.
-
Configure a permanent DNS server via NetworkManager. In the NetworkManager GUI, edit your connection, go to IPv4 settings, and add 8.8.8.8 and 1.1.1.1 as DNS servers.
Setting DNS through NetworkManager ensures the correct servers are used even after reconnecting. Changes to /etc/resolv.conf directly are often overwritten by NetworkManager.
When to Call a Professional
DNS errors are always fixable at home using terminal commands. If DNS resolution fails consistently even after reconfiguring, contact your internet service provider. ISP-level DNS problems require them to fix their servers.
Frequently Asked Questions
What is DNS and why does it matter?
DNS (Domain Name System) is like a phone book for the internet. When you type 'google.com,' your computer asks a DNS server for the IP address of Google's servers. Without DNS, you would need to type the IP address of every website you want to visit. When DNS breaks, websites seem to be down even though the internet connection itself is fine.
Why does /etc/resolv.conf keep getting overwritten on Ubuntu?
Ubuntu uses systemd-resolved to manage DNS, and NetworkManager updates /etc/resolv.conf whenever you connect to a network. If you manually edit /etc/resolv.conf, your changes will be overwritten on the next reconnection. Set DNS servers through NetworkManager or systemd-resolved to make changes permanent.
My DNS works right after boot but stops working after a while. What causes this?
This is often caused by a DNS cache problem, a VPN that modified DNS settings and left them in a bad state, or a router DNS server that becomes unresponsive over time. Try restarting systemd-resolved when the problem occurs to see if it helps. If the issue is with your router, restarting your router periodically may fix it.