Your IP:Unknown

·

Your Status: Unknown

Skip to main content


How to flush DNS: Clear and reset your DNS cache on Windows, Mac, Linux, and web browsers

Your device's DNS cache lets you visit your favorite websites without having to go through DNS resolution every time — but if your DNS records are outdated, you could run into connectivity issues. Read on to learn how to flush DNS records to clear your DNS cache on Windows, Mac, Linux, and your web browser.

Jan 2, 2025

15 min read

How to Flush DNS Cache on Windows, Mac & Linux (Ubuntu)

What is DNS cache?

To understand the role it plays in internet communications, we need to dive a little deeper into what DNS is and what it does.

To connect to a server over a network, your device needs to know its Internet Protocol (IP) address. You could enter the IP address by hand, but it might get tricky since IP addresses are composed of long strings of numbers, which can be easy to mix up or forget.

That's where the Domain Name System comes in. The DNS is a special database that matches domain names to IP addresses. When you type a new web address into your browser, your device first queries its assigned DNS server, only initiating the connection to your desired website once it has the address in hand. And to prevent repeat requests, successful past DNS queries are stored in one temporary place. That’s what a DNS cache is.

How does a DNS cache work?

A DNS cache works just like any other cache — it reserves space on your device to store DNS records that may be required again in the future. Before querying a DNS server, your device will check its DNS cache and, should it find a matching record, connect to the IP address it had stored in its memory. DNS caching greatly speeds up communications because you don't have to go through DNS resolution every time you want to visit the same website.

Because the structure of the internet is fluid, with new servers springing up and old ones getting decommissioned every day, DNS records are rarely permanent. The life expectancy of a DNS entry is measured in seconds and is known as its “Time to Live” (TTL). The entry's TTL value is set by the DNS server and measured in seconds — once the time is up, the record will be automatically purged from the device's DNS cache.

What does “flush DNS” mean?

The “flush DNS” command lets you clear DNS from your cache — that is, manually expunge all held types of DNS records from memory regardless of their remaining TTL. By using flush DNS command, you're basically telling your device that it needs to go through DNS resolution again and obtain new IP addresses for the websites that you used to visit.

Only Windows devices actually accept “flush DNS” as command — other operating systems require you to type something different or choose some other option. However, the “flush DNS” command (or term) has become stuck in our popular culture as a shorthand for any action to clear the DNS cache.

Why should you flush your DNS cache?

While DNS caching can greatly improve your online experience, periodically flushing DNS has some additional practical benefits. Here are a few good reasons why you should flush your DNS cache at least once in a while.

  • Avoiding DNS spoofing. DNS spoofing refers to a wide range of cyberattacks that rely on altering the entries held on DNS servers to redirect victims to fake websites. The malicious DNS entries are distributed to the victims' devices as part of the DNS resolution process and stored in their DNS cache. If your DNS server operators catch wind of what is going on, they will restore the proper values ​​from backups. In that case, flushing your DNS cache will delete all entries (including the bad ones) from your system and let your device fetch a new one.
  • Avoiding DNS cache poisoning. DNS cache poisoning is a specific type of DNS spoofing that exploits the DNS lookup process. When a DNS server doesn't have the requested DNS record on hand, it may query more authoritative servers for additional information. At this point, the hackers can bombard the DNS server with bogus responses to trick it into accepting the fake value as legitimate. Storing this value “poisons” the DNS resolver cache — the bad entry will now be returned to victim devices as part of DNS resolution. Just like with DNS spoofing, flushing your DNS cache will clear any compromised records and allow your device to request new values.
  • Clearing out old DNS entries. Some DNS records simply outstay their welcome. If a website's IP address changes before the associated DNS TTL expires, you could end up running into a wall of “Server IP address could not be found” errors while trying to connect. To get the website's new IP address, flush your DNS cache and enter the desired web address into your browser — your device will query the DNS server again, potentially netting you the new value.
  • Switching to a new DNS server. Most people use the default DNS server assigned to them by their internet service provider (ISP), but that's not often their best option. ISP-assigned DNS servers may hold outdated information, block certain websites, or even compromise your privacy (because your ISP can see which DNS queries come from which IP address). As a result, many people switch to private DNS providers — but if they forget to flush DNS cache records after they change DNS servers, they'll be stuck using their old DNS provider's entries until the TTL expires.
  • Clearing private information. Just like your browsing history, your DNS cache stores information about where you've been online — after all, you wouldn't have a DNS record if you didn't try to visit the associated website. This private information can be dangerous in the wrong hands, such as those of criminals wishing to study your habits for a spear phishing attack. Periodically flushing your DNS cache prevents this sensitive data from accumulating.

How to flush DNS cache on various operating systems and devices

All major operating systems and browsers support DNS cache clearing. The instructions below will teach you how to flush DNS on macOS, Windows, and Linux devices, as well as the popular browsers such as Opera, Firefox, and Google Chrome.

How to flush DNS cache on macOS

  1. 1.Press the smiling blue face icon to open “Finder” and click on “Applications.”
    how to flush DNS 1
    how to flush DNS 2
  2. 2.Open the “Utilities” folder and launch “Terminal.”
    how to flush DNS 3
    how to flush dns 3.2
  3. 3.Based on your OS, type in the appropriate command to flush DNS records.
    • Tiger (10.4): lookupd -flushcache
    • Leopard (10.5), Snow Leopard (10.6): sudo dscacheutil -flushcache
    • Lion (10.7), Mountain Lion (10.8), Mavericks (10.9): sudo killall -HUP mDNSResponder
    • Yosemite (10.10): sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches
    • El Capitan (10.11), Mavericks (10.9): sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
    • Sierra (10.12), High Sierra (10.13), Mojave (10.14), Catalina (10.15), Lion (10.7), Mountain Lion (10.8): sudo killall -HUP mDNSResponder
    • Catalina (10.15), Big Sur (11), Monterey (12), Ventura (13): sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  4. 4.Enter your password and press “Enter.” If you are successful, you will see a message stating that you've reset your DNS cache.

How to flush DNS cache on Windows 

To flush DNS records on a Windows device, you will need to use the command prompt. The process is nearly identical for Windows XP, Windows Vista, Windows 7, and newer Windows OS. Simply follow these steps:

  1. 1.Click the “Start” button in the bottom-left corner of your screen.
    how to flush DNS 4
  2. 2.Open the command prompt.
    • Windows 10, Windows 11: Select “Command prompt” directly from the list or type “cmd” in the search bar.
    • Windows XP, Windows Vista, Windows 7, Windows 8: Click “All programs,” select “Accessories,” and choose “Command prompt.”
      how to flush dns 6
  3. 3.In the command prompt window, type the “ipconfig /flushdns” command.
    how to flush DNS 8
  4. 4.Press “Enter” to confirm. If you are successful, you will see a message stating that the DNS resolver cache has been flushed.

How to flush DNS cache on Linux

The Linux operating system doesn't come with DNS caching capabilities by default — this feature is implemented differently by each distribution. Here is what you need to do to clear DNS records on the most popular versions:

  1. 1.Open the terminal by pressing Ctrl, Alt, and T simultaneously.
  2. 2.Based on your distribution, enter one of the following commands to flush DNS.
    • Ubuntu: sudo systemd-resolve –flush-caches
    • NCSD: sudo /etc/init.d/nscd restart
    • Dnsmasq: sudo /etc/init.d/dnsmasq restart
    • BIND: sudo /etc/init.d/named restart
  3. 3.If prompted, enter your password to confirm that you want to flush DNS cache records.

How to flush DNS cache on mobile devices

Flushing DNS cache on Android or iOS devices typically takes even less steps than on your computer. Here’s what you need to do to flush cache on your mobile device:

  • Android
  1. 1.Open Chrome app.
    how to flush DNS 9
  2. 2. Type “chrome://net-internals/” in the URL bar.
    how to flush DNS 10
  3. 3.Select “DNS.”
    how to flush dns 11
  4. 4.Tap the “Clear host cache” button.
    how to flush dns 12
  • iOS
  1. 1.Go to “Settings.”
    how to flush dns 13
  2. 2.Find “Airplane mode” and tap to toggle it on.pictu
    how to flush DNS 14
  3. 3.Tap again to toggle it off.
    how to flush DNS 15

iOS devices (iPhone and iPad) also allow you to flush DNS cache by simply rebooting the device.

How to flush DNS cache in web browsers

Browsers have their own DNS caches, separate from your operating system. If you flush DNS on your device but not your browser, you could still end up using outdated DNS records while browsing. Here's what you need to do to flush a DNS on Google Chrome, Firefox, and Opera browsers.

  • Google Chrome (follow same steps for DNS flushing on Chromebook)
  1. 1.Open Google Chrome on your device.
  2. 2.Enter “chrome://net-internals/#dns” in the address bar.
    how to flush DNS 16
  3. 3.Click “Clear host cache” to flush DNS records.
    how to flush DNS 17
  • Firefox
  1. 1.Open Firefox on your device.
  2. 2.Enter “about:config” in the address bar and press “Enter.”
    blog screenshot how to flush dns en 18
  3. 3.Click “I accept the risk!” on a warning page.
    blog screenshot how to flush dns en 19
  4. 4.Search for “network.dnsCacheExpiration” in the search field at the top.
    blog screenshot how to flush dns en 20
  5. 5.The search should return two variables named “network.dnsCacheExpiration” and “network.dnsCacheExpirationGracePeriod.”
    how to flush DNS 21
  6. 6.Double-click on each variable’s value part to edit it and then change the value from the default 60 to 0. That will prompt Firefox to flush its DNS cache.
    how to flush DNS 22
  7. 7.Set both variables back to 60.
    how to flush DNS 23

Restart the Firefox browser.

  • Opera
  1. 1.Open Opera on your device.
  2. 2.Enter “opera://net-internals/#dns” in the address bar.
    blog screenshot how to flush dns en 24
  3. 3.Click the button labelled “Clear Host Cache.”
    how to flush DNS 25
  4. 4.Type “opera://net-internals/#sockets” in a new tab.
    how to flush DNS 26
  5. 5.Click the button “Flush socket pools.”
    blog screenshot how to flush dns en 27

Restart Opera browser.

Advanced DNS flush techniques

Some IT professionals may have to deal with more complex cases of DNS flushing (such as server DNS flushing). Here’s a look at some of the advanced DNS flush techniques.

Flushing DNS on servers and domain controllers

You can use at least a few methods to flush DNS on servers and domain controllers. Here are the steps for all of them:

  • Flushing DNS locally on servers and domain controllers
  1. 1.Run PowerShell on server or domain controller with administrator privileges.
  2. 2.Run the “Clear-DnsServerCache” command to flush the DNS cache.
  3. 3.Run the “Get-DnsServerCache” to verify whether the DNS cache has been cleared. If the cache is empty, the output will not show any entries.
  • Flushing DNS cache on domain controllers by running DNS manager console (for Active Directory domain controllers)
  1. 1.Open the DNS manager on the domain controller by typing “dnsmgmt.msc” in the Run dialog or search bar and pressing Enter.
  2. 2.Right-click the server listed in the left pane and select “Clear cache.”
  3. 3.Check the cache folder within the DNS Manager to make sure that the DNS flush was a success. If everything’s in order, the folder should be empty.
  • Flushing DNS cache on Windows server DNS (via Command Prompt)
  1. 1.Open Command Prompt as administrator.
  2. 2.Use the “ipconfig /flushdns” command to flush the DNS cache.
  3. 3.Use the “ipconfig /displaydns” command to make sure the DNS cache is empty. If the command returns no results, DNS flush was a success. 

Troubleshooting DNS flush issues

If DNS flushing does not provide the expected results, it may be useful to troubleshoot the issue and look into different solutions. Here are the most common cases for DNS flush issues and the ways to deal with them:

  • DNS cache doesn’t flush. Make sure you're using the correct command for your operating system (“ipconfig /flushdns” for Windows, “sudo killall -HUP mDNSResponder” for macOS). Double-check if you're running DNS flush as administrator and make sure the firewall or network settings allow DNS flushing commands to go through (if you’re doing a remote DNS flush).
  • DNS resolution failing after flushing DNS cache. Sometimes cached information may still be held in the router or network equipment. Restart your device or router to solve this issue. You can check whether your DNS servers are functioning properly and try switching to a reliable third-party DNS provider.
  • DNS servers are unresponsive after a DNS flush. Make sure your DNS server settings are correct. If you’re using a third-party DNS service, check if the DNS addresses are entered correctly. You can also try switching to a different DNS server (for example, Google's 8.8.8.8 or Cloudflare’s 1.1.1.1).
  • Persistent issues with local network resources (printers, file servers). Ensure that your local DNS server is up-to-date and try flushing the DNS cache on both the local machine and the DNS server. Chances are you might need to restart or reconfigure the internal DNS server if it's not automatically updating records.
  • Cached DNS information still appearing. Clear the DNS cache in your web browser (via browser settings), restart your router, and double-check the local DNS resolver cache.
  • DNS Cache flush causing new problems (such as unreachable websites). Try clearing the cache again, ensure you’re using a reliable DNS server, and consider switching to a more reputable DNS provider if issues persist.
  • Issues with DNS cache flushing on remote systems. Check whether remote DNS flushing is enabled in the network firewall settings. Also, make sure that the relevant ports (e.g., port 53 for DNS) are open and that the remote system’s DNS service is running. You may need to manually restart the DNS service.

Resetting DNS settings and renewing IP address

If troubleshooting fails to provide suitable results, you can also try to reset DNS settings and renew your IP address. This process is especially useful if your device is having trouble connecting to websites or is using outdated or incorrect DNS information. Here’s how to do both on Windows, macOS, and Linux platforms.

  • Windows
  1. 1.Open Command Prompt as an administrator and type the “ipconfig/flushdns” command. This cmd will reset your DNS settings.
  2. 2.Type the “ipconfig /release” command to release the current IP address.
  3. 3.Type the “ipconfig /renew” command to renew the IP address.
  • macOS
  1. 1.Flush your DNS using the Terminal app. This will reset your DNS settings.
  2. 2.Go to “System settings,” then “Network,” and select your active connection (Wi-Fi or Ethernet).
  3. 3.Click on “Advanced,” then “TCP/IP.”
  4. 4.Set the “Configure IPv4” option to “Using DHCP,” then click “Renew DHCP Lease.” This will renew the IP address.
  • Linux
  1. 1.Use the “sudo systemctl restart NetworkManager” command to reset your network settings (may require admin privileges).
  2. 2.Use the “sudo dhclient” command in the terminal to renew your IP.

FAQ

Like what you’re reading?

Get the latest stories and announcements from NordVPN

We won’t spam and you will always have the choice to unsubscribe

Also available in: Italiano.


author Lukas T png

Lukas Tamašiūnas

Lukas Tamašiūnas is a content creator with an interest in the latest developments in the cybersecurity industry. He follows his curiosity to discover and share practical knowledge about online safety.