How to Flush DNS Cache

Most operating systems and browsers store IP addresses and domain name system (DNS) records to complete requests more efficiently. However, sometimes the DNS cache needs to be cleared in order to run effectively. Flushing a DNS cache is simple once you understand how to do it; continue reading below to learn how to flush a DNS cache in Mac, Windows, and popular browsers.

What is a DNS cache and what does it do?

A DNS cache is essentially a file containing information about all visited websites, including the website’s:

  • IP address
  • hostname
  • domain name
  • time to live (TTL)

The DNS cache as a whole is a temporary database maintained by a computer that records previous DNS lookups on a device or web browser on that device. DNS cache records reduce the total number of requests that a computer needs to make to servers when browsing the Internet. This helps move the connection process along, increasing speeds for users.

Essentially, it works like this: the first time you visit a website, the browser must ask the DNS servers where the site is located (requesting its domain name and IP address information). Once the browser knows where the website is located, it can store that information in its local cache. Then, next time you visit that site, the browser can locate the website within its local DNS cache to take you to the website faster.

Flushing your DNS cache helps optimize your system's performance.

Why flush a DNS cache?

The DNS cache is great for speeding up performance, and usually, it works fine. However, it can in some cases lead to various issues, including:

  • security vulnerabilities, when an old, outdated DNS cache leaves you vulnerable to DNS spoofing (an attack where a bad actor gains access to your DNS cache and alters the information to redirect you to malicious websites)
  • corrupted results
  • dangerous IP addresses
  • 404 errors, which happen when outdated DNS records take you to the incorrect location after a website has been updated to a new domain name or host

For these reasons, it’s a good idea to clear your DNS cache periodically.

What does flushing your DNS do?

Flushing your DNS clears the cache, which means that it clears the temporary memory of all websites you’ve recently visited. This allows websites to be updated and clears out any malicious results that may have been saved in the cache unintentionally. Flushing your cache on other devices, like your phone, can do the same thing and help your performance and security.

How to flush DNS cache in Windows and Mac

Clear cache on Windows 10

To flush DNS on Windows 10, simply run the DNS flush command in the command prompt console by following these steps:

  1. Right-click the Windows Start menu, then click Run.
  2. Type cmd, and then click OK.
  3. In the command prompt window, type the flush DNS command: ipconfig /flushdns.
  4. Press Enter.

You should then see the following Windows 10 confirmation message:

Windows IP Configuration

Successfully flushed the DNS Resolver Cache.

Make sure to run as an administrator in order to execute commands in the command prompt that need to access all system security permissions.

Clear cache on MacOS

To flush DNS on Mac operating systems, follow these steps:

  1. Look for Terminal and select it. You can also use Spotlight to search for Terminal with cmd+space.
  2. In the Terminal window, type one of the following according to your MacOS version of software:
    • For Mac OS Sierra, X El Capitan, X Mavericks, X Mountain Lion, X Lion, or X Yosemite, enter sudo discoveryutil udnsflushcaches
    • Snow Leopard, sudo dscacheutil -flushcache
    • Leopard, sudo lookupd -flushcache
    • High Sierra, Mojave, Catalina, Big Sur, or Ventura, sudo killall -HUP mDNSResponder

After entering the command, you should see a confirmation message indicating that the DNS cache was reset. It will confirm that you cleared the DNS cache on MacOS.

Google Chrome and other major browsers store a separate DNS cache from your computer’s operating system. If you want to receive all the benefits of flushing your DNS cache, you have to flush both your operating system and your browser cache.

Clear cache on Google Chrome browser

To flush your DNS cache in Chrome, follow these steps:

  1. Open the Chrome browser.
  2. Type chrome://net-internals/#dns into the address bar and press Enter.
  3. Click Clear host cache.

Clear cache on Firefox browser

To flush your DNS cache in the Firefox browser, follow these steps:

  1. Open the Firefox browser.
  2. Type about:networking#dns into the address bar and press Enter.
  3. Click the Clear DNS Cache button on the page.
  4. Refresh the page by hitting the Refresh button in the top right.

Clear cache on Safari browser

To flush your DNS cache in the Safari browser on a desktop computer or laptop, follow these steps:

  1. Open the Safari browser.
  2. Click on the Safari drop-down menu in the upper left corner of the screen.
  3. Select Settings or Preferences and then Advanced.
  4. Check the Show Develop menu in menu bar box and close the Preferences window.
  5. Select the Develop drop-down menu.
  6. Click Empty Caches.

Frequently asked questions

Is it safe to flush DNS?

Yes, it is completely safe to flush DNS caches periodically. You aren’t erasing any important data; it removes addresses that are outdated, invalid, or just taking up space. You can also flush other caches, like your iPhone cache, to improve performance.

How often should you flush DNS?

There is no specific time limitation on how often you should flush your DNS cache. If you find that you are being redirected to the wrong sites or are being taken to invalid addresses, flush the cache. In general, flush your DNS cache frequently; flush your DNS cache at least once a week to make sure your connection is at its best.

How long does a DNS flush take?

A DNS cache generally takes about fifteen minutes to finish. However, on the user end, it only takes a moment to use the flush DNS command as seen in the instructions above.

Does flushing DNS make the Internet faster?

Yes, flushing the DNS can improve Internet speeds. However, that won’t always be the case. If your DNS cache was full of invalid addresses or redirects, clearing the cache gives the DNS a fresh start to get you to the correct addresses faster. But if the cache had correct IPs stored, it won’t change your Internet speed.