How to flush DNS: A step-by-step guide for Windows, macOS, Linux, and web browsers

How to flush DNS: A step-by-step guide for Windows, macOS, Linux, and web browsers

The steps to flushing DNS varies by operating system and web browser. To flush your computer’s DNS, open your system’s command-line interface and run the DNS deletion commands as an administrator. For browsers, access the DNS management page and select the cache deletion option.

Flushing DNS clears corrupted or outdated data in your system to help resolve connectivity issues and improve security. Whether you’re an administrator or a regular user, knowing how to do it can save you time and frustration.

Short on time? Check out this video tutorial for a quick and easy walkthrough on how to flush DNS.

Subscribe For more educational videos! Hostinger Academy

We’ll cover the steps for each system and explore use cases where this process is helpful. But first, let’s understand what DNS cache is, how it works, and the benefits of clearing it.

What is a DNS cache?

A DNS cache is a file your device creates to remember how to find websites. It stores details like a website’s IP address after you visit it, so your browser can load the site faster next time.

This data comes from a process called a DNS lookup, where your browser contacts a domain name system (DNS) server to get the information.

However, the cache can become outdated or corrupted, which can stop your browser from loading the site correctly. In this situation, you need to clear the DNS cache so your browser can get fresh data.

How to flush DNS cache on different operating systems

The steps to flush the DNS cache differ across operating systems. We’ll explain how to do it on Windows, macOS, and Linux.

How to flush DNS cache on Windows 10 and Windows 11

Flushing DNS on Windows is similar across most versions, especially newer ones. Here’s how:

  1. Click the Start button and look for Command Prompt by entering cmd into the search bar. 
  2. Right-click Command Prompt and select Run as administrator
  3. Enter the following flush DNS command:
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Ipconfig /flushdns
Ipconfig /flushdns
Ipconfig /flushdns

Your system will automatically delete the stored DNS cache and reset the resolver settings. Once the process is complete, you should see a confirmation message in Command Prompt.

Important! Make sure to launch Command Prompt as an administrator. Otherwise, you won’t have the necessary permissions to flush the DNS cache.

How to flush DNS cache in macOS

Flushing the DNS cache in macOS is trickier since it requires different commands depending on the operating system version. However, the general procedure is the same:

  1. Click the magnifying glass icon on the top menu bar. Alternatively, press Command + spacebar
  2. In the Spotlight Search menu, find Terminal. Hit Enter
  3. Based on your MacOS version, type the following command to flush the DNS cache:
    • macOS Big Sur (11), Monterey (12), Ventura (13), Sonoma (14), and Sequoia (15):
      sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
      sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
    • macOS El Capitan (10.11), Sierra (10.12), High Sierra (10.13), Mojave (10.14), or Catalina (10.15):
      sudo killall -HUP mDNSResponder
      sudo killall -HUP mDNSResponder
    • macOS Yosemite (10.10):
      sudo discoveryutil udnsflushcaches
      sudo discoveryutil udnsflushcaches
    • macOS Lion (10.7), Mountain Lion (10.8), or Mavericks (10.9):
      sudo killall -HUP mDNSResponder
      sudo killall -HUP mDNSResponder
    • macOS Snow Leopard (10.6):
      sudo dscacheutil -flushcache
      sudo dscacheutil -flushcache
    • macOS Leopard (10.5):
      sudo lookupd -flushcache
      sudo lookupd -flushcache
  4. If Terminal asks for authorization, enter your user password. This will grant you the required admin privileges to run the command.

On macOS, most DNS cache flush commands usually don’t show a confirmation message, even when they work. If you run the command and don’t see an error, it has likely completed successfully.

You can also check by visiting a website you recently accessed ‒ it’s a good sign if it takes slightly longer to load or the previous error is gone.

Pro Tip

Still having issues? See our guide on DNS server not responding on Windows and macOS for more troubleshooting tips.

How to flush DNS cache in Linux

Commands to clear DNS cache in Linux vary by distribution since they might use different DNS services. For example, Ubuntu uses dnsmasq, while Red Hat Enterprise Linux typically utilizes NCSD.

If you are unsure which DNS service your system uses, check it by running the following command in Terminal. Replace dns_service with dnsmasq, ncsd, or bind:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo systemctl status dns_service
sudo systemctl status dns_service
sudo systemctl status dns_service 

Here’s the general procedure to flush DNS caches on a Linux system:

  1. Press Ctrl + Alt + T to open Terminal. 
  2. Enter these commands according to the DNS service your distribution uses:
    • Dnsmasq:
      sudo /etc/init.d/dnsmasq restart
      sudo /etc/init.d/dnsmasq restart
    • NCSD:
      sudo /etc/init.d/nscd restart
      sudo /etc/init.d/nscd restart
    • BIND:
      sudo /etc/init.d/named restart && sudo rndc restart && sudo rndc exec
      sudo /etc/init.d/named restart && sudo rndc restart && sudo rndc exec
  3. Enter your account password to authorize the command execution. If you log in as root, you can skip this step.

The DNS service will stop briefly and reboot. If systemctl can’t find any of the DNS services, use the following command to flush the cache:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo resolvectl flush-caches
sudo resolvectl flush-caches
sudo resolvectl flush-caches

How to flush DNS cache on web browsers

Since web browsers typically store their own DNS cache, you might need to flush them separately. Here’s how to do it in popular browsers:

  1. Open your web browser. 
  2. In the address bar, enter the following address based on your browser:
    • Google Chrome:
      chrome://net-internals/#dns
      chrome://net-internals/#dns
    • Microsoft Edge:
      edge://net-internals/#dns
      edge://net-internals/#dns 
    • Firefox:
      about:networking#dns
      about:networking#dns
    • Opera:
      opera://net-internals/#dns
      opera://net-internals/#dns
  3. Press Enter to open the DNS management page.
  1. Click the button that says Clear host cache or Clear DNS cache. The name depends on your browser.
  2. Restart your web browser, and it should redownload all the DNS details when you revisit a website.

Important! Safari doesn’t have a page for flushing the DNS cache and uses the system-level configuration instead. This means resetting your macOS system’s DNS will also flush the web browser’s data.

Why flush DNS?

Flushing DNS cache removes outdated or incorrect data that may cause issues when loading websites. While DNS caches usually clear themselves after a set time (known as the time-to-live or TTL), certain situations require a manual reset.

One common situation is dealing with website issues. If a website isn’t loading correctly, clearing DNS cache forces your system to get new data from the DNS server, which can fix problems caused by corrupted or outdated records.

It also helps protect against DNS spoofing. In some cases, attackers can manipulate cached DNS data to redirect you to malicious websites. Flushing the cache removes any tampered entries and restores accurate information.

If you’ve switched to a new DNS provider or recently updated your website’s DNS settings, your system might still rely on old data. Clearing the cache helps your device fetch the latest records, helping websites load correctly and speeding up DNS propagation.

How often should I flush my DNS cache?

You don’t need to flush your DNS cache regularly since it clears itself automatically after a set period. However, it’s a helpful step when you’re troubleshooting website issues, switching DNS providers, or updating domain settings.

Hostinger web hosting banner

Is It safe to flush DNS cache?

Flushing DNS cache is a simple and risk-free way to fix common website issues by removing outdated or incorrect data from your system’s temporary storage. This forces your device to request fresh information from the DNS server.

Some web browsers store their own DNS cache, so it’s useful to know how to clear it on your operating system and browser. Flushing at the system level usually requires administrator access, while doing it on a browser is more straightforward ‒ just a button click on a DNS management page.

When done correctly, deleting DNS cache can help websites load properly, protect against DNS spoofing, and speed up DNS propagation after changes.

All of the tutorial content on this website is subject to Hostinger's rigorous editorial standards and values.

Author
The author

Aris Sentika

Aris is a Content Writer specializing in Linux and WordPress development. He has a passion for networking, front-end web development, and server administration. By combining his IT and writing experience, Aris creates content that helps people easily understand complex technical topics to start their online journey. Follow him on LinkedIn.