How To Flush DNS in Windows, Mac and Linux

Webmaster might need to Flush DNS when you are changing Nameserver or updating DNS. And for user when some website you visit frequently updating their DNS, you also need to flush your DNS to see the change immediately. Here I will share super simple process to flush dns cache.

Flush DNS


In general DNS cache takes time to expire. If you need to resolve new updated DNS or clean your cache you need to flush dns. Here is how to do it easily in all Operation system.

Flush DNS in Windows

1. Open Command Prompt
Win Key + R ->> type cmd ->> Press Enter

2. Now Flush DNS from Command Prompt
Type
ipconfig /flushdns
flush dns in Windows

3. Open the link in browser you are trying to resolve DNS. Sometime you need to restart browser and clean Browser cache and cookies.

Flush DNS in Mac

1. Launch Terminal

2. Type the following command

OS X Mountain Lion or Lion (Mac OS X 10.7 and above)
sudo killall -HUP mDNSResponder

Mac OS X 10.5 and 10.6
sudo dscacheutil -flushcache

Mac OS X 10.4 And Below
lookupd -flushcache
Flush DNS in Mac

3. Open the link in browser you are trying to resolve DNS. Sometime you need to restart browser and clean Browser cache and cookies.

Flush DNS in Linux

Flush nscd dns cache

If you are using Nscd, you have to restart it. Run any of the following command

$ sudo /etc/init.d/nscd restart

Or

$ service nscd restart

Or

$ service nscd reload

Flush dnsmasq dns cache

If you are using Dnsmasq, you have to restart it. Run any of the following command

$ sudo /etc/init.d/dnsmasq restart

Or

$ service dnsmasq restart

Flush BIND dns cache
If you are using BIND dns, you have to restart it. Run any of the following command

$ /etc/init.d/named restart

You can also use rndc command
$ rndc restart

Or

$ rndc exec

For a particular domain

$ rndc flushname masifrahman.com

It is also possible to flush lan and wan BIND views using the following command

$ rndc flush lan

or

$ rndc flush wan

BTW for Linux the location could be dependent on distros and package. So, you have to adjust command according to your system. If you are running Linux assuming you know that much or you have to know that much.

Note: Yes, you could just edit your hosts file too. But I personally try to avoid it, as I think putting hardcoded IP in hosts file is not really dynamic.

Resource:

1) Apple Support KBHT5343
2) Hongkiat

Leave a Reply

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