The Domain Name System (DNS) cache is a temporary database maintained by your computer’s operating system. It stores information about recent DNS lookups, so your system can quickly resolve domain names to IP addresses without needing to query DNS servers continuously. Sometimes, it’s necessary to flush the DNS cache to resolve connectivity issues or improve internet performance. This article will guide you on how to flush DNS on all major operating systems: Windows, macOS, and Linux.

Why You Might Need to Flush DNS

Before we dive into the steps for flushing DNS, let’s understand why you might need to do it:

  • Website Not Loading: If a website you frequently visit changes its IP address, your computer may still try to visit the old IP, resulting in errors.
  • Improved Security: Flushing the DNS cache can remove malicious entries, safeguarding your browsing.
  • Internet Performance: A fresh DNS cache can speed up your internet connection by removing outdated DNS records.

Flushing DNS on Windows

Flushing the DNS cache on Windows can help resolve various connectivity issues. Here are the steps for different versions:

Windows 10, 8, and 7

  1. Open the Start Menu and type cmd in the search bar.
  2. Right-click on Command Prompt and select Run as administrator.
  3. In the Command Prompt window, type the following command and press Enter:
    ipconfig /flushdns
  4. You should see a confirmation message that the DNS Resolver Cache has been flushed.

Flushing DNS on macOS

Mac users can also flush their DNS cache to improve internet performance. Here are the steps:

macOS Monterey and Big Sur

  1. Open the Terminal application. You can find it using Spotlight Search (Cmd + Space) or in the Applications > Utilities folder.
  2. Enter the following command and press Enter:
    sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  3. You will need to enter your administrator password to execute the command.

macOS Catalina, Mojave, and Earlier

  1. Open the Terminal application.
  2. Type the following command and press Enter:
    sudo killall -HUP mDNSResponder
  3. You will need to enter your administrator password to execute the command.

Flushing DNS on Linux

Linux distributions, such as Ubuntu, also have ways to clear the DNS cache. Here are general steps:

Using systemd-resolved Service

On systems using systemd-resolved, you can flush the DNS using the following commands:

  1. Open a terminal.
  2. Type the following command and press Enter:
    sudo systemd-resolve --flush-caches
  3. You may need to enter your sudo password to execute the command.

Using nscd Service

For systems using the nscd service:

  1. Open a terminal.
  2. Type the following command and press Enter:
    sudo /etc/init.d/nscd restart
  3. You may need to enter your sudo password to execute the command.

Verifying DNS Cache Flush

After flush DNS, you might want to verify it has been successfully cleared. Here are commands for different operating systems:

  • Windows: Type ipconfig /displaydns in the Command Prompt.
  • macOS: Use the dscacheutil -cachedump -entries host command in Terminal.
  • Linux: You can use different methods based on your DNS server. For example, systemd-resolve --statistics.

Conclusion

Flushing your DNS cache is a simple yet effective way to resolve various internet issues. Depending on your operating system, the steps may slightly differ, but the result is always the same – a refreshed DNS cache for improved browsing performance.

OS Command
Windows ipconfig /flushdns
macOS Monterey/Big Sur sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
macOS Catalina/Mojave sudo killall -HUP mDNSResponder
Linux (systemd-resolved) sudo systemd-resolve --flush-caches
Linux (nscd) sudo /etc/init.d/nscd restart