Table of Contents
How to Flush DNS Cache on Windows, Mac and Linux
If you have ever experienced issues loading websites, encountered outdated IP addresses, or noticed that DNS changes are not taking effect, the solution is often straightforward: flush DNS cache. This simple yet powerful action clears the stored DNS records on your device, forcing it to fetch fresh information from the DNS server. In this guide, we will walk you through exactly how to flush DNS cache on Windows, Mac, and Linux, so you can resolve connectivity issues quickly and efficiently.
What Is DNS Cache and Why Does It Matter?
DNS, or Domain Name System, acts as the internet’s phonebook. When you visit a website, your device sends a query to a DNS server to translate the human-readable domain name (such as example.com) into a machine-readable IP address. To speed up this process, your operating system stores these translations locally in a DNS cache.
Over time, this cache can become outdated or corrupted. If a website changes its IP address, your device may still be pointing to the old address stored in the cache. This can result in slow loading times, error messages, or an inability to access certain websites altogether. Flushing the DNS cache removes all stored records, prompting your system to retrieve accurate, up-to-date information.
Knowing when and how to flush DNS cache is a valuable skill for anyone who manages websites, troubleshoots network issues, or simply wants to keep their browsing experience running smoothly. For more helpful technical guides, visit the DA Manager blog.
How to Flush DNS Cache on Windows
Windows makes it relatively simple to flush the DNS cache using the Command Prompt. The process is quick and only takes a few seconds.
Step-by-Step Instructions for Windows
Follow these steps to flush DNS cache on any version of Windows, including Windows 10 and Windows 11:
- Press the Windows key on your keyboard or click the Start menu.
- Type cmd into the search bar.
- Right-click on Command Prompt and select Run as administrator. This ensures you have the necessary permissions to clear the cache.
- In the Command Prompt window, type the following command and press Enter:
ipconfig /flushdns
You should see a confirmation message that reads: Successfully flushed the DNS Resolver Cache. This means the process has completed successfully.
Additional DNS Commands for Windows
While you have the Command Prompt open, there are a couple of other useful commands worth knowing. To display the current DNS cache, type ipconfig /displaydns. To register your DNS records, use ipconfig /registerdns. These commands can be helpful when diagnosing more complex network issues.
How to Flush DNS Cache on Mac
Flushing the DNS cache on a Mac varies slightly depending on the version of macOS you are running. Apple has changed the command required in different versions of its operating system, so it is important to use the correct one for your system.
Flushing DNS Cache on macOS Monterey, Ventura, and Sonoma
For the most recent versions of macOS, the process involves using the Terminal application:
- Open Finder and navigate to Applications > Utilities > Terminal, or use Spotlight Search (Command + Space) and type Terminal.
- Enter the following command and press Return:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Unlike Windows, macOS does not display a confirmation message after the command runs successfully. If no error appears, the cache has been flushed.
Flushing DNS Cache on Older macOS Versions
If you are running an older version of macOS, the command differs slightly:
- macOS High Sierra, Sierra, and El Capitan:
sudo killall -HUP mDNSResponder - macOS Yosemite:
sudo discoveryutil udnsflushcaches - macOS Mavericks and earlier:
sudo dscacheutil -flushcache
Always ensure you are using the correct command for your specific macOS version to avoid errors.
How to Flush DNS Cache on Linux
Linux is a more varied operating system, with different distributions handling DNS caching in different ways. Not all Linux systems cache DNS by default, but many modern distributions use either systemd-resolved or nscd to manage DNS.
Flushing DNS Cache Using systemd-resolved
If your Linux distribution uses systemd-resolved (common in Ubuntu 18.04 and later, as well as many other modern distributions), use the following command:
sudo systemd-resolve --flush-caches
To confirm the cache has been cleared, you can check the statistics with:
sudo systemd-resolve --statistics
Look for the Current Cache Size value โ it should be zero after flushing.
Flushing DNS Cache Using nscd
If your system uses the Name Service Cache Daemon (nscd), you can flush the DNS cache by restarting the service:
sudo service nscd restart
Or, on systems using systemctl:
sudo systemctl restart nscd
Flushing DNS Cache Using dnsmasq
Some Linux distributions use dnsmasq as a DNS caching service. To flush the cache, restart dnsmasq with the following command:
sudo systemctl restart dnsmasq
If you are unsure which DNS caching service your Linux distribution uses, check your system documentation or run systemctl list-units --type=service to see active services.
When Should You Flush DNS Cache?
Knowing how to flush DNS cache is only half the battle โ understanding when to do it is equally important. Here are some common scenarios where flushing the DNS cache is recommended:
- Website not loading correctly: If a site you know is live is not displaying, a stale DNS record may be the culprit.
- DNS changes not propagating: After updating DNS records for a domain, flushing the cache can help your device pick up the new settings faster.
- Security concerns: DNS cache poisoning is a type of cyberattack where malicious actors corrupt your DNS cache to redirect traffic. Flushing the cache can help mitigate this risk.
- After changing DNS servers: If you have recently switched to a different DNS provider, flushing the cache ensures your device uses the new server immediately.
Final Thoughts
Learning how to flush DNS cache on Windows, Mac, and Linux is a fundamental skill that can save you a great deal of time and frustration when dealing with network issues. Whether you are a web developer, IT professional, or everyday user, clearing your DNS cache is one of the first troubleshooting steps you should take when experiencing connectivity problems.
The process is quick, safe, and requires no specialist tools โ just a command line and a few seconds of your time. Bookmark this guide so you always have the correct commands to hand, and remember to check your operating system version before running any commands, particularly on macOS and Linux where the syntax can vary.
With a fresh DNS cache, your device will be able to resolve domain names accurately and efficiently, helping you get back online without unnecessary delays.














