DNS cache can be corrupted for a number of different reasons, including network attacks or viruses.

When that happens, IP address mapping becomes corrupted for certain popular websites. For example, instead of going to www.facebook.com, your browser may redirect you to an IP address of a malicious website that an attacker inserted in your computer’s DNS records. Or, you may get a large number of 404 errors.

Clearing DNS cache deletes all saved DNS lookup information. Your computer then gets updated data from DNS servers next time it sends a lookup request.

How To Clear DNS Cache in Windows

Clearing cache is an easy and quick process. The procedure is the same for almost all Windows systems. We used Windows 10 in this example.

To flush DNS on your Windows machine:

  1. Load the Command Prompt as an administrator. Open the Start Menu and start typing command prompt until you see it in the results.windows command prompt
  2. Type ipconfig /flushdns when the prompt loads and hit enter on the keyboard.flushing with windows example of ipconfig
  3. The process should take only a few seconds. You should see the DNS Resolver Cache confirmation message when it’s done:successfully flushed dns cache

The DNS Cache database on your computer is now clear. You should get the correct and updated IP mapping from DNS servers next time your machine sends a DNS query.

Clear DNS Cache on a Mac

There are a few different commands to use for flushing DNS cache on OS X and macOS depending on the version you are running.

As the procedure is the same on all versions, we will show how to clear DNS on macOS Mojave (10.14) and then list the commands for other versions in a table.

Flush DNS on macOS Mojave (version 10.14)

To clear DNS cache on macOS Mojave, use the Terminal application:

  1. Run the terminal.app using your preferred method. You can launch the app from Applications -> Utilities or press Command + Space to launch Spotlight and search for Terminal.
  2. Type in sudo killall -HUP mDNSResponder and hit Return on your keyboard.
  3. Enter the administrator password for the account in question and hit Return.

There is no notification when the process finishes. However, you can append another command to change that.

Tip: If you want to hear an audio notification after the DNS flush is complete, type say some text after the first command, for example:
sudo killall -HUP mDNSResponder; say dns cleared successfully

Commands for Flushing DNS Cache on Older macOS and Mac OS X Versions

The table below lists the commands for clearing the DNS cache on most macOS and Mac OS X versions. You can copy and paste them directly from the table into your terminal.

Mac OS X or macOS version
Mojave (version 10.14)
High Sierra (version 10.13)
Sierra (version 10.12)
Mountain Lion (version 10.8)
Lion (version 10.7)
El Capitan (version 10.11)
Mavericks (version 10.9)
Yosemite (version 10.10)
Snow Leopard (version 10.6)
Leopard (version 10.5)
Tiger (version 10.4)
The Command for Terminal
sudo killall -HUP mDNSResponder
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches
sudo dscacheutil -flushcache
lookupd -flushcache

How to Flush DNS Cache in Linux

Linux distributions are a bit different from Windows and Mac machines. They use specific DNS services.

It depends which service you have in your distribution and if the system enabled it by default. Some of them are NCSD(Name Service Caching Daemon), dnsmasq, BIND (Berkely Internet Name Domain).

For every distribution, you need to launch Terminal. Press Ctrl + Alt + T on your keyboard and use the corresponding command to clear the DNS cache for the service your Linux system is running.

linux dns clear cache command line

Flush Local NCSD DNS Cache

Use this command to clear NCSD DNS cache on your Linux machine:

sudo /etc/init.d/nscd restart

Enter your password if necessary. The process stops and then starts the NCSD service within seconds.

Flush Local dnsmasq DNS Cache

Use this command to clear the dnsmasq DNS cache on your Linux machine:

sudo /etc/init.d/dnsmasq restart

Again, enter your password if the terminal asks you. You will see the response when the service stops and starts again.

Flush Local BIND DNS Cache

If you use BIND for DNS service, there are a few commands you can use to flush its DNS cache. You may need to enter your password to finish the process.

  • sudo /etc/init.d/named restart
  • sudo rndc restart
  • sudo rndc exec

Tip: BIND also allows you to target specific domains when performing a DNS flush. Just append flushname and the domain name to the sudo rndc command. For example:
sudo rndc flushname phoenixnap.com


Here you learned how to clear or flush DNS cache on various operating systems.

The Internet we use today would not be the same without the immense work Domain Name Systems are doing. We as users may not be aware of how many processes occur before we can see a webpage or receive an email.