DNS

How to flush a DNS
cache on Windows
and Mac

Flushing your DNS cache is an easy, effective way to keep your local cache secure and troubleshoot DNS and connectivity errors.

What is DNS caching and how does it work?

A DNS lookup process is initiated each time you enter a URL into your web browser’s address bar. Before requesting the IP address from root, TLD and authoritative nameservers, your recursive resolver (usually assigned by your internet service provider) will check to see if the requested information is in cache.

A DNS cache stores resource records (RR) from all recently visited sites until the domain’s DNS records’ time to live (TTL) has expired, after which time the DNS lookup process must be repeated the next time you attempt to visit the site.

Why you should flush your DNS cache

While a DNS cache helps web pages load faster by streamlining the DNS lookup process, periodically clearing out the cache can help with both security and performance by facilitating troubleshooting DNS errors, ensuring the RR in your local cache are up to date and protecting against DNS cache poisoning and spoofing.

DNS record propagation

DNS record updates can take as long as 24-48 hours to propagate across all servers worldwide, so the information in cache can become outdated. This can cause certain sites or applications to misbehave and may cause websites to display incorrectly or show old images and text. Clearing your web browser cache can help, but it isn’t always enough.

DNS cache poisoning

A form of spoofing called DNS cache poisoning happens when users are led to fake sites created by cybercriminals to capture personal and sensitive information. DNS caches can be intercepted by hackers, who then manipulate or add new IP addresses to the fake website. Flushing your cache can protect against DNS cache poisoning. After flushing your cache, your recursive resolver will need to acquire an authoritative answer the next time you attempt to visit a website, preventing you from visiting a fake site and thwarting potential attacks.

How do I clear my DNS cache?

The steps you follow to clear your DNS cache will vary depending on your operating system.

How to flush your DNS server cache on Windows

Use the Command prompt or PowerShell to flush your DNS cache on Windows.

To access Windows Command Prompt, press Win + R to pull up the Run command. Type cmd and click Okay.

Alternatively, click on the search icon in your taskbar and type “command prompt” or “cmd.” The app should be displayed at the top of the search window under “Best match.”

View current DNS cache

You may wish to see what’s currently in your DNS cache before clearing it. You can do this by using the following command:

Command prompt:

Follow these steps to view your DNS cache in Windows Prompt:

  • Open CMD 
  • In the command line, type the following: ipconfig /displaydns
  • Press Enter

This will display the items currently in your DNS cache.

PowerShell

Follow these steps to view your DNS cache in PowerShell:

  • Open PowerShell 
  • In the command line, type the following: Get-DnsClientCache
  • Press Enter

Clear DNS cache with Command Prompt

  • Open CMD
  • In the command line, type the following: ipconfig /flushdns
  • Press Enter 
  • If the process is successful, a confirmation message will appear in your Command Prompt console.

This will clear out the DNS cache on the client side (your local cache).

Clear DNS cache with PowerShell

  • Open PowerShell
  • In the command line, type the following: Clear-DnsClientCache
  • Press Enter

How to flush your DNS server cache on Mac

  • Use Spotlight Search or press Command + Space, then type Terminal.
  • Double click the Terminal application icon.
  • Type the following: sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder
  • Enter your Mac password when prompted.
  • Press Enter.

How often should I clear my DNS cache?

The process of flushing your DNS cache takes approximately 15 minutes and has no negative impact, so you may clear yours as frequently as you like. We recommend flushing the DNS cache as needed to address errors and on a regular schedule that’s convenient for you to reduce vulnerabilities and maintain optimal performance.