flush dns cache windows mac linux

How to Flush DNS Cache in Windows, Linux & Mac

DNS cache saves information about domain name resolution of queries domains on your system so that browsers can quickly lookup websites the next time they are requested from your system. However, sometimes they may get corrupted and start directing users to unknown websites & IP addresses, on requesting a domain. In such cases, you may need to clear DNS cache so that your system retrieves updated information from DBS server and stores it on your system. In this article, we will look at how to flush DNS cache in Windows, Linux & Mac.


How to Flush DNS Cache in Windows, Linux & Mac

Windows, Linux & Mac systems store DNS resolution information such as Resource data, Record type, Record name, TTL (Time to Live), Class, etc. Let us look at how to flush DNS cache in Mac, Windows & Linux.


How to Flush DNS Cache in Mac

1. Open terminal from Applications-> Utilities or press Command+Space to open spotlight and search for terminal.

2. Enter the following command to flush DNS

sudo killall -HUP mDNSResponder

3. You will be asked to enter administrator password. Enter it to start command execution.

Please note, there is no message or response when the DNS cache is flushed.


How to Flush DNS Cache in Windows

Here are the steps to flush DNS cache in Windows.

1. Open Command Prompt by opening Start Menu and searching for ‘command prompt’. Click the top search result to open Command Prompt.

2. Enter the following command to clear DNS cache.

ipconfig /flushdns

It will take a few seconds to complete. On successful execution, you will see ‘Successfully flushed the DNS Resolver Cache’

Now your system will update its DNS cache from records retrieved from DNS server, when a domain/website is requested from your system.


How to Clear DNS Cache in Linux

Linux systems have different DNS cache systems – some run NSCD (Name Service Caching Daemon), dnsmasq and BIND.

We will look at how to flush cache in each of these systems. In each case, you will need to open terminal and run commands. In some cases, you may be asked for administrator password too.

Clear DNS Cache in NSCD

Open terminal and run the following command to flush cache in NSCD.

$ sudo /etc/init.d/nscd restart

Clear DNS Cache in dnsmasq

Open terminal and run the following command to clear DNS cache in dnsmasq.

$ sudo /etc/init.d/dnsmasq restart

Clear DNS Cache in BIND

Open terminal and run any of the following commands to flush DNS cache.

$ sudo /etc/init.d/named restart
OR
$ sudo rndc restart
OR
$ sudo rndc exec

In this article, we have learnt how to clear DNS cache in Mac, Windows & Linux.

Also read:

How to Change Host Name in Debian/Ubuntu
How to Send GET & POST requests in Python
How to Create Swap File in Linux
SFTP Script to Transfer File in Linux
How to Reverse String in Python

Leave a Reply

Your email address will not be published. Required fields are marked *