What is DNS Flushing? How to flush DNS Cache in Windows, Linux and Mac OS?

Tech Insights

A DNS Cache is a temporary, local database that contains all the records of a computer’s recent visits to websites. It helps your computer or browser to resolve the website’s URL quickly. To read more about DNS Cache and how to view the DNS Cache entries, read this post.

Why to flush DNS Cache frequently? Top reasons to keep the DNS Cache correct and up to date.

1) If one of your visited websites has a hostname change, the local DNS Cache entry will become incorrect. Clearing the browser cache or history will not have any effect in this case since the DNS Cache entry is still pointing to the old IP.

2) DNS cache poisoning or DNS spoofing

DNS cache poisoning or DNS spoofing is a cyber threat in which a virus or an attacker inserts incorrect domain names or IP addresses into the DNS Cache. With a poisoned DNS Cache, entering a website’s URL will take you to some other location or website than you were trying to visit. This might result in compromising your sensitive data.

3) Privacy and security issues

Anyone getting access to the cache means getting access to the personal web usage data.

4) Resolving network issues

If you are administrating a network and troubleshooting some issues, it’s advised to ensure that the DNS Cache records are correct.

How to clear DNS Cache in Windows, Linux and Mac OS?

1) Windows

In MS Windows, you can easily flush the local DNS cache by going to the command prompt and executing the following command:

ipconfig /flushdns

2) Linux

The process of clearing DNS Cache differs depending on the Linux distribution. Each distribution might use a different DNS service.

2.1) If your OS uses name service caching daemon(NSCD), execute the following command to clear the DNS Cache:

sudo /etc/init.d/nscd restart

2.2) If your OS uses DNSMasq as a caching server, execute the following command:

sudo /etc/init.d/dnsmasq restart

2.3) If your OS uses systemd-resolved, execute the following command:

sudo systemd-resolve --flush-caches

To ensure systemd-resolved is being used by the system, execute the following command:

sudo systemctl is-active systemd-resolved.service

If the service is running, the command will print the result as active. Otherwise, it will print inactive.

3) Mac OS

For the latest versions of Mac OS, execute the following command to flush the DNS Cache:

sudo killall -HUP mDNSResponder

For earlier versions, the command to flush the cache differs:

3.1) Mac OS version 10.11 and 10.9

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

3.2) Mac OS version 10.10

sudo discoveryutil mdnsflushcache
sudo discoveryutil udnsflushcaches

3.3) Mac OS version 10.6 and 10.5

sudo dscacheutil -flushcache

1 thought on “What is DNS Flushing? How to flush DNS Cache in Windows, Linux and Mac OS?

Comments are closed.