How to Flush DNS Cache on Mac, Windows, and Linux

How to Flush DNS Cache

Flushing the DNS cache is a common troubleshooting step to resolve network connectivity issues, such as unable to access a website, experiencing a “Page not found” (404) error for a site you know exists, or seeing an outdated version of a website. Well, DNS cache is a temporary database maintained by your operating system that contains records of recent visits and attempted visits to websites, including their domain names and corresponding IP addresses. Usually, when you visit a website (e.g., www.example.com), your device performs a DNS (Domain Name System) lookup to translate the human-readable domain name into a machine-readable IP address (e.g., 93.184.216.34). And to speed up future visits, your operating system or web browser stores this information in the DNS cache. However, if a website’s IP address changes, your computer might still have the old information stored in its cache. Flushing the DNS cache forces your computer to perform a new lookup and get the most current information. Here is how to flush DNS cache and fix internet connectivity problems on

“Flushing” is simply the process of emptying out the cache records.

What Is DNS Cache?

The DNS cache is a temporary database maintained by your operating system. It stores information about previous DNS lookups basically a record of the websites you’ve visited and their corresponding IP addresses.

When you visit a website, your system checks the DNS cache first to find the IP address linked to that domain. If it’s outdated or corrupted, you might not reach the site properly. That’s when flushing the DNS cache becomes useful.

So, flushing the DNS cache:

  • Fixes problems where websites fail to load or load incorrectly due to outdated DNS records.
  • Ensures your system uses the latest DNS information after a server or domain change.
  • Clears potentially corrupted or malicious DNS entries.

Now let’s explore how to flush the DNS cache on each operating system.

How to Flush DNS Cache on Mac

If you’re using a Mac, the method to flush DNS cache depends on your macOS version. Here’s how to do it on recent versions (macOS Monterey, Ventura, and newer):

macOS uses a service called mDNSResponder to manage DNS caching.

  • Open Terminal (Press Command + Space, type “Terminal”, and hit Enter).
  • Run the command: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  • Enter your password when prompted.

How to Flush DNS Cache on Mac

You won’t see a confirmation message, but the command will execute silently. Your DNS cache is now cleared.

How to Flush DNS Cache on Windows

Windows stores DNS information to speed up website access. Flushing the DNS cache in Windows is quick and easy, whether you’re using Windows 10 or 11.

  • Press Windows + R to open the Run dialog.
  • Type cmd and press Ctrl + Shift + Enter to run Command Prompt as Administrator.
  • In the Command Prompt window, type: ipconfig /flushdns and Press Enter.

You’ll see a message: “Successfully flushed the DNS Resolver Cache.

Flush DNS cache command

How to Flush DNS Cache on Linux

On Linux, the DNS caching behavior depends on the system and which DNS service you’re using (like systemd-resolved, nscd, or dnsmasq).

Press Ctrl + Alt + T (Ubuntu) or open your preferred terminal application.

  • For systemd-resolved (Ubuntu 18.04+): sudo systemd-resolve –flush-caches
  • For nscd (Name Service Cache Daemon): sudo service nscd restart or try sudo /etc/init.d/nscd restart
  • For dnsmasq: sudo service dnsmasq restart

How to Flush DNS Cache on Linux

If you are not sure which service you’re using? You can check by running: ps ax | grep -E ‘nscd|dnsmasq|systemd-resolved’

Note:

  • Not all Linux distributions cache DNS. If systemd-resolved or other caching services aren’t installed, no flush is needed.
  • You may need root or sudo privileges to execute these commands.
  • Restart your browser or network service if issues persist.

In addition, flushing the DNS cache may not immediately resolve issues. Restarting your device or browser can help. If problems continue, verify your internet connection or contact your ISP.

Also consider switching to a public DNS service like Google DNS (8.8.8.8) or Cloudflare (1.1.1.1) for faster and more reliable browsing.

Why Flush DNS Cache?

There are several reasons you might want to flush your DNS cache:

  • Website Not Loading: If a website has moved to a new server or has a new IP address, your DNS cache might still hold the old IP address, causing the site to load incorrectly.
  • Privacy Concerns: Flushing the DNS cache can remove traces of websites you’ve visited.
  • Security: A corrupted DNS cache can lead to security vulnerabilities such as DNS spoofing or cache poisoning.
  • Troubleshooting: General network troubleshooting steps often include flushing the DNS cache to resolve various connectivity issues.

Kelvin smith

I am Kelvin Smith, founder of TechAIThreads. I have completed a Bachelor of Arts (BA) and am a Microsoft Certified Professional (MCP). With a strong background in computer applications, I love writing practical guides on Microsoft Windows (11, 10, etc.), Android, cybersecurity, WordPress, and more.