Back to Blog

How to Flush DNS: Windows, macOS and Linux

How to flush the DNS cache: ipconfig /flushdns on Windows, macOS and Linux commands, browsers, phones, routers, and the Google and Cloudflare DNS caches.

Nodesty Team5 min readHosting
The words Flush DNS with ipconfig, resolvectl and TTL on a dark Nodesty background

The DNS cache is a set of temporary records in which your computer and browser keep the IP addresses of domain names you've visited before for a while. It makes sites open faster, but when a site's DNS record changes, it causes the old address to keep being used for a while. If you've moved a site to a new server, changed a DNS setting or are getting an error like "DNS_PROBE" on a site, flushing the cache often fixes the problem right away.

This guide covers how to flush the DNS cache on Windows, macOS and Linux, in browsers, on phones and on your router, how to refresh the cache of public DNS servers, and what to check when the change still doesn't show up.

Why does the DNS cache exist?

Keeping the answer for a while instead of asking DNS every time you visit a site makes pages open faster. How long it's kept is set by the record's TTL (Time To Live) value. The cache is kept in several layers:

  1. Browser: Chrome and Firefox keep their own small caches.
  2. Operating system: Windows, macOS and Linux keep a system-wide cache.
  3. Router: Many home routers keep their own DNS cache.
  4. DNS server: The cache of your internet provider's DNS server or the public DNS server you use.

To see a change, the old record has to expire or be flushed in every layer that holds it. We explain how DNS works in our What is DNS? article.

Flushing the DNS cache on Windows

Open Command Prompt or PowerShell as administrator and type:

ipconfig /flushdns

You'll see the message "Successfully flushed the DNS Resolver Cache." To see the records in the cache, you can use the ipconfig /displaydns command.

Flushing the DNS cache on macOS

Open Terminal and type:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

You'll be asked for your Mac's password. When the command succeeds, it doesn't show any message.

Flushing the DNS cache on Linux

On distributions that use systemd-resolved, including current Ubuntu and Debian releases:

sudo resolvectl flush-caches
resolvectl statistics

The second command shows the number of records in the cache; after flushing, it should be close to zero. If your system uses nscd or dnsmasq, restart that service:

sudo systemctl restart nscd

Flushing the DNS cache in browsers

  • Chrome and Edge: Type chrome://net-internals/#dns (in Edge, edge://net-internals/#dns) in the address bar and press the Clear host cache button. You can also close open connections with Flush socket pools in the Sockets section of the same page.
  • Firefox: Type about:networking#dns in the address bar and press the Clear DNS Cache button.

Fully closing and reopening the browser also clears the browser cache.

On your phone and router

  • Android and iPhone: The easiest way to flush the DNS cache on a phone is to turn airplane mode on for a few seconds and then off, or to turn Wi-Fi off and on. Restarting the phone also clears the cache.
  • Router: Turning your router off and back on after a few seconds clears the router's DNS cache.

Refreshing the Google and Cloudflare DNS cache

If your computer uses Google Public DNS (8.8.8.8) or Cloudflare (1.1.1.1), you can ask these services to refresh the record they keep for a specific domain name:

  • Google Public DNS: On Google's Flush Cache page, choose the domain name and record type and flush the cache.
  • Cloudflare 1.1.1.1: Enter the domain name and record type on the 1.1.1.1/purge-cache page.

You can't flush your internet provider's DNS server cache, though; the record refreshes on its own when its TTL expires. If you don't want to wait, you can temporarily switch your computer's DNS setting to one of these public DNS servers.

If the change still doesn't show up

  1. Ask different DNS servers. Check whether the record has really changed:
    nslookup yourdomain.com 1.1.1.1
    dig @8.8.8.8 yourdomain.com +short
    

    If the public DNS servers show the new address, the problem is only on your computer or with your provider.
  2. Check the hosts file. A line added to the hosts file for testing during a site migration stays in effect even if the cache is flushed. Look at C:\Windows\System32\drivers\etc\hosts on Windows and /etc/hosts on macOS and Linux. We cover testing with this file in our Website migration guide.
  3. Check the TTL. The number in the dig output shows, in seconds, how much longer the record will be kept in the cache.
  4. Wait for the nameserver change. If you changed your domain's nameservers, the change can take 24–48 hours to propagate.
  5. Isn't it the browser cache? If the page itself looks old, the problem may not be DNS but the browser's page cache or a CDN; in that case, force-refresh the page or purge the CDN cache. The details are in our What is a CDN? article.

A tip for next time: If you lower the record's TTL to 300 seconds at least a day before a DNS change, the change shows up in most places within a few minutes.

DNS with Nodesty

On Nodesty web hosting plans, you put your site live by pointing your domain's nameservers or A record to your hosting account; you can manage your DNS records from cPanel or DirectAdmin. If you're moving a site or application to an AMD Ryzen 9 9950X VPS, lowering the TTL before you point the A record to your server's IP address speeds up the switch.

Frequently Asked Questions

Is it safe to flush the DNS cache?

Yes. The DNS cache only holds temporary records of the IP addresses of domain names. When you flush it, no data or settings are lost; your computer fetches the records from the DNS server again on your next visit. The first page loads may take a few milliseconds longer.

I flushed the cache but the site still shows the old server. Why?

The cache isn't only on your computer. Your browser, your router and your internet provider's DNS server also keep the record until its TTL expires. The old record may still be in one of them. Check with a different DNS server and see whether there's an old line in your hosts file.

Can I flush my internet provider's DNS cache?

No, your provider's DNS server isn't under your control; the record refreshes on its own when its TTL expires. If you don't want to wait, you can temporarily switch your computer's DNS setting to a public DNS server such as Google or Cloudflare.

How often should I flush the DNS cache?

You don't need to flush it regularly. It's enough to flush it only when you change a site's DNS record, when you get a DNS error reaching a site, or when you still see the old version of a site even though it has moved to a new server.

How long does it take for my DNS change to propagate everywhere?

It depends on the record's TTL value. If the TTL is 300 seconds, the change shows up in most places within a few minutes; if it's 86400 seconds, it can take up to a day. Nameserver changes can take 24–48 hours. Lowering the TTL before the change speeds up the switch.

Does the hosts file affect the DNS cache?

Lines written in the hosts file are used before the DNS lookup and stay in effect even if the cache is flushed. If a line added for testing during a site migration is forgotten, your computer keeps going to the old or wrong server. Check your hosts file too before flushing the cache.

Nodesty

About the author

Nodesty Team · Infrastructure & Support

The Nodesty team runs our servers, network and DDoS protection day to day and answers customer support requests around the clock. These guides come from that work.

Related articles

Launch your server now.

Build, scale, and conquer without limits on Nodesty's premium infrastructure.

                                                                                                                                                                                                                            
                                                                                                                                                                                                                            
                                                                                                                                                                                                                            
                                                                                                                             ············································                                                   
                                                ··································································································..........···························                                     
                                       ················..........................................................................................................................··············                             
                                  ·············.................::::::::::::::::::::::::::::::::::::::::::::::....................:::::::::::::::::::::::::::::::::::::::................···········                        
                             ············................:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::............·········                     
                         ············.................:::::::::::::::::::::::::::::::::::::::::::::::::::------------::::::::::::::::::::::::::::::----------------:::::::::::::::::::::..........········                  
                    ············......................::::::::::::::::::::::::::::::::::::------------------------------------------------------------------------------------:::::::::::::.........········                
                ··········.............................................::::::::::::::::::-------------==========================================-----------------------------------:::::::::::........·······               
             ········..................:.....................................::::::::::--------=======+++++++++++++++++++++++++++++++++++++=========================------------------::::::::::.......·······              
           ······.........::::::::::::::::::::................................:::::::-----=====++++xxxxxx**************************xxxxxxxxx++++++++++++++===================------------::::::::.......·······             
          ·····.......:::::::::::::::::::::::::::.............................:::::----===+++xxx****%%%%&&&&&&#############&&&&&&&%%%%%*******xxxxxxxx++++++++++++++==============----------:::::::......······             
         ····......::::::::-------------:::::::::::..........................::::---===+++xx***%%%&&&####@@@@@@@@@@@@@@@@@@@@@@@@####&&&&&%%%%*******xxxxxxxxx+++++++++++++===========--------::::::......·····             
        ····.....:::::::--------------------:::::::::.......................::::---===++xxx**%%&&&###@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@###&&&&%%%%%********xxxxxxxxxxx++++++++++++========------::::::.....······            
        ····.....:::::--------------------------::::::::....................::::---===++xx***%%&&&####@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@###&&&&&%%%%%**********xxxxxxxxxxxxx+++++++++=======------:::::.....·····            
        ····....::::::-------=============---------:::::::::................:::::---===+++xx***%%%&&&#####@@@@@@@@@@@@@@@@@@@@@@@@@#####&&&&&%%%%%%*************xxxxxxxxxxxxxx+++++++++======-----:::::....·····            
         ····....:::::-------================---------:::::::::...............:::::----===++++xxx***%%%%&&&&&&#################&&&&&&%%%%%%%*******************xxxxxxxxxxxxxxxxx++++++++======----:::::....·····            
         ·····....:::::--------=================---------::::::::::..............:::::::-----====+++++xxxxxx**************************xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx++++++++=====-----::::....·····            
          ·····.....:::::--------=================----------:::::::::::.................:::::::::-------=============++++++++++++++++++++++++++++++++++++xxxxxxxxxxxxxxxxxxxxxxx++++++++======-----::::....·····            
            ·····.....:::::::----------===========-------------::::::::::::.........................::::::::::::::::::------------------=============+++++++++++++++++++++++++++++++++=======-----::::.....·····            
              ······......:::::::---------------------------------:::::::::::::........................................:::::::::::::::-----------============+++++++++++++++++++++========------:::::.....·····             
                 ······........:::::::::---------------------------:::::::::::::::::...........................................:::::::::::::------------=============================--------::::::.....······              
                    ·········.........:::::::::::::::-------------::::::::::::::::::::::::.......................................::::::::::::::::--------------------------------------::::::::......·······                
                          ··········............::::::::::::::::::::::::::::::::::::::::::::::::::................................::::::::::::::::::::::::::-------------:::::::::::::::.........········                   
                                  ············..................:::::::::::::::::::::::::::::::::::::::::::.........................:::::::::::::::::::::::::::::::::::::................···········                        
                                             ················.............................................................................................................·················                                 
                                                           ······················................................................................···························                                                
                                                                               ·········································································