Support

Find answers, guides, and tutorials to supercharge your content delivery.

What Is DNS Cache and How to Flush It

Updated on March 31, 2023
What Is DNS Cache and How to Flush It

We've covered the topic of what a DNS server is in the past and explained how they work. Basically, a DNS server is used to resolve a particular domain to its IP equivalent. However, this process takes time since once a new website request is made, the client must ask the resolver, which asks the root server, which asks the TLD server, for information. Needless to say, each additional check, adds extra time that the visitor must wait to receive a response.

Luckily, there is a mechanism in place to help reduce the frequency of which a website visitor's browser must request a complete DNS lookup. This is called DNS cache. In this article, we'll further explain what DNS cache is as well as outline how to flush your DNS cache.

What is DNS cache?

DNS cache refers to the temporary storage of information about previous DNS lookups on a machine's OS or web browser. Keeping a local copy of a DNS lookup allows your OS or browser to quickly retrieve it and thus a website's URL can be resolved to its corresponding IP much more efficiently. The basic function of different cache types is all more or less the same. However, if you need a more comprehensive explanation of cache, check out our cache definition article.

DNS caching does not only occur at the OS and browser level. In fact, as mentioned above, a DNS lookup involves various steps. During a new DNS lookup, the lookup passes through the resolver, root server, and TLD server. At each step, information is gathered and cached for later use. Therefore, even if the local DNS cache is empty, the resolver may have a cached copy of the required information thus, avoiding the need to go through the complete DNS lookup process.

Why do you need to flush DNS cache?

While DNS cache can speed up your browsing experience, it can also cause issues if the cached information becomes outdated or corrupt. For example, if a website changes its IP address, but your computer still has the old IP address in its cache, you won't be able to connect to the website. Similarly, if the DNS cache becomes corrupt, it can cause connection issues.

Flushing the DNS cache clears out all the cached DNS information on your computer. This forces your computer to request fresh DNS information from the DNS server the next time you connect to a website. Flushing the DNS cache can help resolve connection issues caused by outdated or corrupt DNS information.

Checking your DNS cache

You can check your operating system's logs to see which DNS records are cached locally. The process for this will vary depending upon which operating system you use however, we've outlined how to achieve this on both Windows and Mac.

  • Window - The process for viewing your DNS cache entries in Windows is pretty simple. Simply open your command prompt and enter the following command: ipconfig /displaydns.
  • Mac - The process for viewing your DNS cache entries on a Mac is a little different. You'll need to first open the Console app, select your device from the left sidebar and enter: any:mdnsresponder into the search bar. Next, open your command line and enter the following command: sudo killall -INFO mDNSResponder. You should then be able to go back to your console app and see the list of cached DNS records. For example, the screenshot below shows a cached CNAME record for edge.skype.com.

Additionally, you can also check your DNS cache entries on certain browsers. For example, if you're using Chrome, you can enter: chrome://net-internals/#dns into your address bar which will return your browser's current list of cached DNS records.

How to flush DNS cache

Depending upon your operating system or browser, the method used to flush your DNS cache will vary. As for why you would want to flush your DNS cache, this may vary as well. A couple of reasons include:

  • Troubleshooting connectivity issues
  • Troubleshooting and/or resolving DNS spoofing (e.g. DNS cache poisoning) issues
  • Resolving stale content issues (e.g. if a website has moved servers)

How to flush DNS cache on Windows

If you're using a Windows computer, here's how to flush the DNS cache:

  1. Open the Command Prompt by pressing the Windows key + R, typing cmd in the Run dialog box, and pressing Enter.
  2. Type the following command and press Enter: ipconfig /flushdns
  3. You should see a message that says "Successfully flushed the DNS Resolver Cache."

That's it! You have now successfully flushed the DNS cache on your Windows computer.

How to flush DNS cache on Mac

If you're using a Mac, here's how to flush the DNS cache:

  1. Open the Terminal app by going to Applications > Utilities > Terminal.
  2. Type the following command and press Enter: sudo killall -HUP mDNSResponder
  3. You will be prompted to enter your Mac's password. Enter your password and press Enter.
  4. You should see a message that says "mDNSResponder: restarted."

That's it! You have now successfully flushed the DNS cache on your Mac.

How to flush DNS cache on Linux

If you're using a Linux computer, here's how to flush the DNS cache:

  1. Open the Terminal app by pressing Ctrl + Alt + T.
  2. Type the following command and press Enter: sudo systemd-resolve --flush-caches
  3. You should see a message that says "Cache cleared."

That's it! You have now successfully flushed the DNS cache on your Linux computer.

Additionally, to clear the DNS cache in Chrome browsers, navigate to chrome://net-internals/#dns and click the "Clear Host Cache" button.

Certain DNS servers such as Google's Public DNS even allow you to flush the cache of a domain. Therefore, if you've recently changed DNS servers for your site and want to ensure that everyone who is using Google's Public DNS will receive the latest version of your site you can use their flush cache tool.

Learn more about this tool in their FAQ section.

Summary

DNS cache is a very efficient way to avoid having to complete an entire DNS lookup each time you visit a site. Instead, this process will only need to occur the first time you visit the site and upon subsequent requests, your machine will use the OS's and browser's cached DNS information until it expires or is flushed.

If you need to flush or check your DNS cache for any one of the reasons mentioned above, simply follow the instructions that relate your specific OS.

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started
KeyCDN uses cookies to make its website easier to use. Learn more