How to Clear (Flush) the DNS Cache on Windows, MacOS & Linux

Estimated reading: 3 minutes 646 views

DNS cache is a temporary database that stores information about previous DNS lookups. In other words, whenever you visit a website, your OS and web browser will keep a record for the domain and the corresponding IP address. This eliminates the need for repetitive queries to the remote DNS servers and allows your OS or browser to resolve the website’s URL quickly.

However, in some situations like troubleshooting network issues or after changing DNS resolvers, you will need to flush the DNS cache. This will clear the cached DNS entries and perform a subsequent lookup to resolve the domain based on newly configured DNS settings.

This article provides instructions on how to flush the DNS cache on different operating systems and web browsers.

1.Clear/Flush DNS Cache on Windows

  • Type cmd in the Windows search bar.

  • On the command line, type the following line and press Enter:
ipconfig /flushdns

Output:

2. Clear/Flush DNS Cache on Linux

  • Systemd Resolved

The easiest way to flush the DNS on Linux, if you are using systemd-resolved, is to use the “systemd-resolve” command followed by “–flush-caches”.

Alternatively, you can use the “resolvectl” command followed by the “flush-caches” option.

Most modern Linux distributions such as Ubuntu 20.04 are using systemd resolved service to cache DNS entries.

To find out whether the service is running use the following command:

$ sudo systemctl is-active systemd-resolved.service

If the service is running, the command will print active. Otherwise, you will see inactive.

To clear the Systemd Resolved DNS cache, type:

$ sudo systemd-resolve --flush-caches

In order to verify that your Linux DNS cache was actually flushed, you can use the “–statistics” option that will highlight the “Current Cache Size” under the “Cache” section.

$ sudo systemd-resolve --statistics

Congratulations, you successfully flushed your DNS cache on Linux!

3.Clear/Flush DNS Cache on macOS

The command to flush cache in macOS is slightly different depending on the version you’re running. The command must be executed as a user with system administrator privileges (sudo user).

To clear the DNS cache in macOS, perform the following steps:

Step 1: Open the Finder.

Step 2: Go to Applications > Utilities > Terminal. This will open up the Terminal window.

Step 3: In the command line, type the following line and press Enter:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Enter your sudo password, and hit Enter again. On success, the system doesn’t return any message.

For earlier versions of macOS, the command to flush cache is different.

4.Conclusion

We’ve shown you how to clear or flush DNS cache on Windows, Linux, and macOS operating systems.

Linux and macOS users can use the dig command to query and troubleshoot DNS issues.

Good Luck!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Leave a Comment

Share this Doc

How to Clear (Flush) the DNS Cache on Windows, MacOS & Linux

Or copy link

CONTENTS