Flush DNS on Linux to Fix Connectivity Issues

Flush DNS on Linux to Fix Connectivity Issues

Flushing the DNS cache on AlmaLinux (a RHEL-based distribution) can help resolve certain connectivity issues related to outdated or corrupted DNS entries.

Here’s how to flush the DNS cache depending on the DNS resolver your system is using:

Why This Helps

Flushing the DNS cache removes outdated or corrupted DNS records, which can:

  • Fix website not loading issues
  • Resolve problems after a DNS server change
  • Clear out bad domain entries

🔹 1. Check Which DNS Service is Running

Most modern RHEL-based systems use systemd-resolved, but others may use dnsmasq or nscd.

sudo systemctl list-units –type=service | grep -E ‘resolved|dnsmasq|nscd’


🔹 2. Flush DNS Cache Based on Service

✅ If using systemd-resolved (most common on newer systems):

sudo systemd-resolve –flush-caches

Optional: Check stats (to confirm cache was flushed):

systemd-resolve –statistics


✅ If using nscd (Name Service Cache Daemon):

sudo systemctl restart nscd

Or:

nscd -i hosts


✅ If using dnsmasq:

systemctl restart dnsmasq


🔹 3. Clear DNS Cache in Web Browser

Sometimes, DNS is cached in the browser as well. Restart your browser or clear its DNS cache manually.


🔹 4. Restart NetworkManager (if needed)

If you’re still having issues, try restarting NetworkManager:

systemctl restart NetworkManager


Confirm It Worked

You can test DNS resolution with:

dig example.com

or

nslookup example.com

 Flush DNS on Windows to Fix Connectivity Issues

Open Command Prompt as Administrator

  • Press Windows Key + S, type cmd or Command Prompt.
  • Right-click on Command Prompt and select Run as administrator.

 Run the DNS Flush Command

·        In the Command Prompt window, type the following command and press Enter:

ipconfig /flushdns

 Success Message

  • You should see a message:

Successfully flushed the DNS Resolver Cache.