How to Fix DNS Issues on Linux

Resolve DNS issues on Linux and clear stale network cache with help from Kudu.

By Kudu Team

Fix this automatically with Kudu

Run a free system scan to detect and resolve this issue automatically — no manual steps required.

Download Kudu Free →

What Causes This?

DNS issues on Linux usually happen when your system is using the wrong DNS server, a local DNS cache has gone stale, or your network manager has written a bad resolv.conf setting. The problem can also come from a VPN, firewall, router, or ISP blocking or misrouting DNS requests. In some cases, the internet connection itself works, but name lookups fail, so websites and apps cannot translate domain names into IP addresses.

Common Symptoms

  • Websites fail to load, but you can still ping a public IP like 8.8.8.8
  • Errors such as “Temporary failure in name resolution” or “DNS_PROBE_FINISHED_BAD_CONFIG”
  • Package managers like apt, dnf, or yum cannot reach repositories
  • Some apps connect slowly or say the server cannot be found
  • DNS starts working again after reconnecting to Wi-Fi or rebooting

How to Fix It Manually

  1. Check whether DNS is the actual problem

    • Open a terminal.
    • Run:
      ping -c 4 8.8.8.8
    • If this works, test DNS directly:
      ping -c 4 google.com
    • If the IP ping works but the domain ping fails, DNS is likely the issue.
  2. See which DNS servers your system is using

    • In the terminal, run:
      cat /etc/resolv.conf
    • Look for nameserver entries.
    • If the file is empty, missing valid servers, or shows a broken local address, that can explain the problem.
  3. Try a known good DNS server

    • Temporarily set public DNS servers:
      sudo nano /etc/resolv.conf
    • Add or replace with:
      nameserver 1.1.1.1
      nameserver 8.8.8.8
    • Save the file and test again:
      ping -c 4 google.com
    • If this fixes it, your previous DNS server was likely the problem.
  4. Flush the local DNS cache

    • Different Linux systems use different DNS services. Try the one that matches your setup:
      sudo systemd-resolve --flush-caches
      or
      sudo resolvectl flush-caches
      or restart the resolver service:
      sudo systemctl restart systemd-resolved
    • If you use nscd, restart it:
      sudo systemctl restart nscd
  5. Restart your network connection

    • If you use NetworkManager:
      sudo systemctl restart NetworkManager
    • Then disconnect and reconnect Wi-Fi or Ethernet.
    • Test DNS again with:
      nslookup google.com
      If nslookup is not installed, use:
      getent hosts google.com
  6. Check for VPN, firewall, or router interference

    • Disconnect any VPN and test again.
    • If you changed firewall rules recently, temporarily disable them to test.
    • Restart your router, then reconnect your Linux machine.
    • If DNS only fails on one network, the router or ISP DNS may be the cause.
  7. Make the DNS change permanent

    • If your system overwrites /etc/resolv.conf, update DNS through NetworkManager instead:
      nmcli con show
    • Find your active connection name, then set DNS:
      sudo nmcli con mod "Your Connection Name" ipv4.dns "1.1.1.1 8.8.8.8"
      sudo nmcli con mod "Your Connection Name" ipv4.ignore-auto-dns yes
      sudo nmcli con up "Your Connection Name"
    • This prevents bad DNS values from returning after reboot or reconnect.

Fix It Automatically with Kudu

If you do not want to dig through DNS settings, cache services, and network configuration by hand, Kudu can help automate the cleanup. It can detect stale network cache, repair common connectivity issues, and apply safe fixes faster than manual troubleshooting.

Download Kudu Free →

Fix this automatically with Kudu

Run a free system scan to detect and resolve this issue automatically — no manual steps required.

Download Kudu Free →