How to Flush the DNS Cache on Windows, Linux, and macOS
Introduction
DNS cache stores recently resolved domain names on your computer to improve browsing speed. However, after changing DNS records, updating nameservers, or pointing a domain to a new server, your system may continue using the old cached information.
Flushing the DNS cache forces your computer to retrieve the latest DNS records, helping resolve domain propagation and connectivity issues.
Prerequisites
Before you begin, ensure you have:
- Access to the local computer
- Administrator or sudo privileges (if required)
- A terminal or command prompt
Implementation
Flush DNS Cache on Windows
Open Command Prompt and run:
ipconfig /flushdns
If successful, you should see a message indicating that the DNS Resolver Cache has been successfully flushed.
Flush DNS Cache on Linux
If your system uses the nscd service, restart it using:
/etc/init.d/nscd restart
or
/etc/rc.d/init.d/nscd restart
This clears the DNS cache maintained by the nscd daemon.
Flush DNS Cache on macOS
For older versions of macOS, run:
lookupd -flushcache
For Mac OS X Leopard, use:
dscacheutil -flushcache
This clears the local DNS resolver cache.
Conclusion
Flushing the DNS cache is a quick and effective way to refresh your computer’s DNS records. It is particularly useful after changing DNS settings, updating nameservers, migrating a website, or troubleshooting domain resolution issues. Once the cache is cleared, your system will retrieve the latest DNS information from the configured DNS servers.
