Home » Tech Tips » Windows » What is DNS Cache and How to Flush it in Windows PC?

What is DNS Cache and How to Flush it in Windows PC?

You might have heard the term “flushing DNS and wondered what it means. DNS is an acronym for “Domain Name System”, which in essence, is a phone book for the internet. It helps to resolve the descriptive domain name or site address (like webnots.com) entered in the browser’s address bar into a numeric IP address quickly. The numeric IP address is the location of a physical server where the content you are looking for is stored.

What is DNS Cache?

Now that you know what is DNS, the next thing is that “Cache”. Your computer also stores the DNS lookup details in a cache to make the internet connection faster. Over the period of time you visit lot of websites, play online games and do other browsing activities. All these activities will make your DNS cache fills with a DNS IP addresses to all the websites that you have visited on the internet. Whenever you visit the webpages again, your computer will refer the DNS cache and resolve the IP address much faster. Now you feel the websites are loaded faster compared to the first time.

Below picture indicates how the resolving of IP address works in general. Besides the caching at your local PC and browser, DNS caching happens at different levels like origin and gateway servers. The purpose of all these caching is to speed up the loading of webpages without looking up every time.

Resolving Host Process
Resolving Host Process

Why Should You Flush DNS?

It is common to have problems with your internet connection in terms of speed and broken layouts of websites. It’s usually a good indication that you need to flush your DNS, especially if you see errors like 504 gateway timeout, 502 bad gateway or the page is not loading only on your PC (but loads on your mobile and other devices). DNS related errors generally happens due to the changes occurred on previously accessed DNS servers or the website is moved to another server. In these situations, loading of the webpages may take long time or even will never load at all. This is because your computer may still be processing old information or DNS addresses from the DNS cache.

Flushing your DNS essentially wipes the lookup details that you have accumulated and refreshes it with fresh information when you open the sites again. Before flushing the DNS, simply disconnect the device from internet and restart your router/modem. Once the modem has come back online, turn on the internet connection on your computer. This is more of a simple way to fix the problems related to your router/modem.

View DNS Cache in Windows

Before flushing the DNS you can actually view the cached records.

  • Hold down the “Windows key” and press the “R” key. This will open up your “Run” window like below.
Open Command Prompt in Windows
Open Command Prompt in Windows
  • Type in “cmd” and press the enter key to open the Command Prompt app.
  • Type ipconfig /displaydns in the prompt and press enter. It will show you the list of records cached by your PC.
Display DNS in Window
Display DNS in Window

If you want to test whether DNS caching is working on your PC, just open any of the website. Let us open our own website – webnots.com. Now, go back to Command Prompt and display the DNS. You will see some entries like below indicating the DNS details (like CNAME and A records) are cached.

Record Name......: www.webnots.com
Record Type......: 5
Time to Live.....: 407
Data Length......: 4
Section..........: Answer
CNAME Record.....: webnots.com

It should look like below in the Command Prompt:

Testing DNS Cache
Testing DNS Cache

Flush DNS Cache in Windows

If you see any of the IP addresses are wrong or you couldn’t conclude, then just flush it to clear the cache. Type ipconfig /flushdns and press enter. Windows will flush the DNS and show a success message as “Successfully flushed the DNS Resolver Cache”.

Flush DNS in Windows
Flush DNS in Windows

Make sure that you include the space between “ipconfig” and the “/”, otherwise it’ll come up with an error, that looks something like this.

Error Message Due to Wrong Command
Error Message Due to Wrong Command

You can again test the DNS cache by using ipconfig /displaydns command. The website details shown previously should have been removed now. The process works on all Windows versions like Windows 7, 8, 10 and 11 as those are standard commands.

Additional Points

1. What about using Windows PowerShell app?

Yes, you can also use the same commands in Windows PowerShell instead of Command Prompt.

2. Will flushing DNS disconnect the internet?

No. It simply removes cached DNS records, forcing your computer to obtain fresh information the next time you access a website.

3. How often should I flush my DNS cache?

There’s no strict rule, flush it whenever noticing connectivity issues or after changing DNS servers.

4. Does flushing DNS improve speed?

It may improve speed if your cache contains outdated or incorrect entries. Otherwise, it won’t have a noticeable effect.

5. Is there a way to automate DNS flushing?

Yes, you can create a batch file with the ipconfig /flushdns command and schedule it using Windows Task Scheduler.

6. I am still facing DNS problems, what should I do?

If you notice problems with the DNS provided by your Internet Service Provider (ISP), change to public DNS from Google or any other service provider as explained in this article.

7. What is the impact of using a VPN?

VPN apps may change the behavior of DNS cache as all your internet activities will be routed through the VPN server’s DNS instead of your ISP’s DNS. So, if you have any problem with speed or flushing cache, disable the VPN app or delete VPN profiles installed on your PC and then try again.

Leave a Comment

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