How to Flush DNS Cache

How to Flush DNS Cache

If you’re having connection issues, you might want to clear your DNS Cache. This may sound like a complicated and technical process, but it’s much easier than you might think.

In fact, flushing the DNS Cache requires no technical knowledge, especially if you have a detailed step-by-step tutorial to follow.

In this article, you’ll learn what a DNS Cache is, why you may need to flush your DNS Cache, and the many different ways to go about it using flush DNS command.

 

What Is DNS Cache?

Similar to web browsers, operating systems also store cache files of previous Domain Name System (DNS) lookups in what is called the DNS cache. It consists of compressed information units called resources records (RR) about all visited websites, displayed in ASCII code.

The following are a DNS cache’s components:

  • Resource data ‒ contains a record’s description, such as the address and hostname.
  • Record type ‒ describes the record’s type (A or AAAA record).
  • Record name ‒ showcases the DNS entry’s domain name.
  • Time To Live (TTL) ‒ the resource record’s validity time measured in seconds.
  • Class ‒ the resource record’s appropriate protocol group.
  • Resource data length ‒ refers to the resource data’s value.

When visiting a website for the first time, the user’s’ operating system stores that site’s DNS cache files. It streamlines the DNS lookup process by resolving domains to their IP addresses, making web pages load faster the next time you visit the same IP address.

Reasons to Flush DNS Cache Periodically

Most operating systems perform DNS caching to lessen the DNS servers’ burden during high traffic. Its TTL determines the cache’s validity period. As long as the cache files are still valid, they will answer content requests without going through the DNS server.

Despite this, using corrupt or outdated DNS cache files can lead to errors and security vulnerabilities. Your operating system may store a bad DNS cache when you visit websites that just moved to a new domain name or host. Therefore, we recommend flushing your DNS cache periodically.

Here are the reasons why you should clear your DNS cache regularly:

  • To prevent search behavior tracking ‒ storing DNS records makes it easier for hackers to predict your browser history.
  • Security ‒ DNS cache files are the main target for DNS spoofing, which endangers users’ sensitive information like login credentials and personal data.
  • To solve technical problems ‒ forcing the operating system to search updated DNS records can solve connection issues and incorrectly displayed web content.

Ways to Flush DNS Cache

Depending on your operating system, the steps to flushing a DNS cache may vary. The tutorial below will show you how to do it on Windows, Linux, and Mac OS X.

Microsoft Windows

On Microsoft Windows flush DNS cache is a relatively simple process. Keep in mind that you need to run as administrator when executing the command prompt to access all system security permissions. 

Here are the steps to flushing DNS cache on Windows XP, 7, Vista, 8, 8.1, and 10.

  1. Press Windows+R keys together or right-click Windows’ Start menu and then click Run. Type cmd to open the Windows command prompt console. If you don’t have administrator privileges yet, run the cmd command by pressing Ctrl+Shift+Enter.
  2. Type ipconfig /flushdns on the command prompt and press enter. This command will clear DNS cache files on your computer and reset the DNS resolver cache.
  3. If the process is successful, you’ll see the confirmation message on your command prompt as follows:
    Screenshot showing confirmation message on Microsoft Windows

Linux

By default, Ubuntu doesn’t cache DNS records. If you manually install a DNS service like name service caching daemon (nscd), the steps below will show you how to flush DNS cache on your computer. Make sure to run as administrator when following these steps.

  1. Press Ctrl+Alt+T keys together to open the terminal window.
  2. Enter the following command line to clear DNS cache files on the init.d subdirectory:
sudo /etc/init.d/nscd restart

Here is the guide to flush the DNS cache on a system that uses systemd.

  1. Press Ctrl+Alt+T keys together to open the terminal window.
  2. Type the following command line:
systemd-resolve --flush-caches
  1. Enter the following in the command prompt to check whether or not the previous command has successfully flushed the DNS cache.
systemd-resolve --statistics

Mac OS X

While the steps to flushing a DNS cache on Mac OS X are simple, you need to run the right flush DNS command based on your current OS X version.

  1. Press the F4 key, then enter terminal in the Launchpad’s search field to open the command terminal window.
  2. If you’re using Mac OS Sierra, X El Capitan, X Mavericks, X Mountain Lion, or X Lion, the next step is to enter the following in the command prompt:
sudo killall -HUP mDNSResponder
  1. To flush DNS cache on Mac OS X Yosemite, enter the command:
sudo discoveryutil udnsflushcaches
  1. If you’re running on Mac OS X Snow Leopard, use the command:
sudo dscacheutil -flushcache
  1. For Mac OS X Leopard and below, enter the following command to flush DNS cache:
sudo lookupd -flushcache
  1. To flush DNS cache on Mac OS X High Sierra, enter this in the command prompt:
sudo killall -HUP mDNSResponder
  1. Here is the command to flush DNS cache on Mac OS X Mojave:
sudo killall -HUP mDNSResponder
  1. If you’re running on Mac OS X Catalina, use this command:
sudo killall -HUP mDNSResponder
  1. Here is the command to flush DNS cache on Mac OS X Big Sur:
sudo dscacheutil -flushcache; 
sudo killall -HUP mDNSResponder

Flush Your DNS Cache in Google Chrome

As Google Chrome stores a separate DNS cache from the operating system on your computer, flushing them will have the same benefits. This is particularly important if you use Google Chrome as your main web browser.

Keep in mind that this cache type is different from the browser cache. 

Here are the steps to do it:

  1. Open Google Chrome and enter the following address into its address bar:
chrome://net-internals/#dns
  1. On the net internal settings page, select Clear host cache.
Screenshot showing how to clear host cache

Conclusion

When experiencing connection issues or seeing incorrectly displayed web pages, your system might be storing corrupted or outdated DNS cache records. You can quickly solve it by using flush DNS command. If doing so doesn’t resolve the problem, try to clear your web browser cache instead.

We hope you find this article helpful in solving DNS server issues. Good luck.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

What do I need to do to put Flash on my website?

Flash is a client side feature - it runs on the user's computer, not on your web host. As long as...

What are private nameservers and how do I set them up?

Private nameservers are where your domain points to our nameservers so that your customers do not...

Static IP vs. Dynamic IP Address

A static IP address is one that remains fixed and never changes. The PC always sees the same...

Protecting Yourself Against Viruses & Data Loss

It is vital to ensure your computer is protected from viruses and trojans. As well as...

How to Upgrade perl?

Run the following command. cd /usr/local/src ; wget...