How to Flush DNS Cache in macOS, Windows, & Linux?

The Domain Name System (DNS) translates numerical IP addresses into readable domain names, making it easier to access websites. When your computer connects to the internet, it stores DNS information in a local cache to speed up future requests. However, this cached information can become outdated or corrupted, requiring you to flush the DNS cache to resolve connectivity issues.

What is DNS Cache?

When a computer or device connects to the internet, it saves a copy of DNS information in its memory cache called the DNS cache. This cache stores domain names, their corresponding IP addresses, and other related data from previous requests. The purpose is to speed up future requests for the same domain name and reduce network traffic by avoiding repeated lookups.

Why Flush DNS Cache?

Sometimes cached information becomes outdated or corrupted, causing problems when trying to connect to websites. For example, if a website changes its hosting provider and updates its IP address, but your system still holds the old address information in the DNS cache, you won't be able to access that website properly. Flushing the DNS cache clears these stale entries and forces your system to retrieve fresh DNS information.

How to Flush DNS Cache in macOS

Using Terminal Command

The quickest way to flush DNS cache on macOS is through the Terminal:

  • Open Terminal from Applications > Utilities or press Cmd + Space and search for "Terminal"

  • Enter the following command:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  • Press Enter and type your admin password when prompted

  • Press Enter again to execute the command

Using System Preferences

Alternatively, you can flush DNS cache through System Preferences:

  • Open System Preferences from the Apple menu

  • Go to Network > Advanced > DNS tab

  • Click the minus (-) button next to existing DNS servers

  • Click Apply and then OK

  • Add your preferred DNS servers back and click Apply

How to Flush DNS Cache in Windows

Using Command Prompt

The most common method to flush DNS cache in Windows:

  • Press Windows + R, type cmd, and press Ctrl + Shift + Enter to run as administrator

  • Enter the following command:

ipconfig /flushdns
  • Press Enter and you should see a confirmation message

  • To verify the cache is cleared, use:

ipconfig /displaydns

Using PowerShell

Windows PowerShell provides an alternative method:

  • Press Windows + X and select "Windows PowerShell (Admin)"

  • Enter the following command:

Clear-DnsClientCache
  • Press Enter to execute

  • Verify with ipconfig /displaydns which should show an empty list

How to Flush DNS Cache in Linux

Flushing nscd Daemon Cache

The nscd (Name Service Caching Daemon) caches DNS lookups on many Linux distributions. To flush its cache:

sudo systemctl restart nscd.service

Or alternatively:

sudo /etc/init.d/nscd restart

Flushing systemd-resolved Cache

On systems using systemd-resolved (Ubuntu 16.04+, many modern distributions):

sudo systemd-resolve --flush-caches

To verify the cache has been cleared, check statistics:

sudo systemd-resolve --statistics

Alternative Methods

For other Linux distributions, try these commands:

# For dnsmasq
sudo service dnsmasq restart

# For BIND
sudo rndc flush

Comparison of Methods

Operating System Primary Method Alternative Method Verification Command
macOS Terminal command System Preferences dig command
Windows ipconfig /flushdns PowerShell Clear-DnsClientCache ipconfig /displaydns
Linux systemd-resolve --flush-caches nscd restart systemd-resolve --statistics

Troubleshooting Common Issues

No Internet Connection After Flushing

If you lose internet connectivity after flushing DNS cache:

  • Restart your router and modem

  • Reboot your computer

  • Check DNS server settings and ensure they're configured correctly

  • Try using public DNS servers like Google (8.8.8.8, 8.8.4.4) or Cloudflare (1.1.1.1)

DNS Resolution Issues

If domain names aren't resolving properly:

  • Test connectivity with ping google.com

  • Check your DNS server configuration

  • Verify network connection stability

  • Consider switching to different DNS servers temporarily

Conclusion

Flushing DNS cache is a straightforward process across macOS, Windows, and Linux that can resolve many network connectivity issues. Each operating system provides multiple methods, with command-line approaches being the most reliable and efficient. Regular DNS cache flushing helps maintain optimal network performance and ensures you're accessing the most current IP addresses for websites.

Updated on: 2026-03-17T09:01:38+05:30

523 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements