How to Clear Local DNS Cache on Windows, Mac and Browsers
In this article
To clear your local DNS cache, you must perform a "DNS flush" using a system command or browser setting depending on your operating system. On Windows, this is done via the Command Prompt using ipconfig /flushdns, while on macOS, it is done through the Terminal using the sudo dscacheutil -flushcache command.
Understanding the Local DNS Cache
The Domain Name System (DNS) acts as the phonebook of the internet, translating human-readable domain names like example.com into machine-readable IP addresses like 192.0.2.1. To avoid querying a DNS server every single time you visit a website, your operating system and web browser store a local copy of these translations in a temporary storage area called the DNS cache.
While caching significantly speeds up browsing by reducing latency, it can cause problems when a website changes its server or IP address. If your local cache still holds the old IP address, your computer will attempt to connect to a server that is no longer hosting the site, resulting in a "404 Not Found" error, a "Server Not Found" message, or a connection timeout.
How to Flush DNS on Windows
Windows maintains its own system-level DNS cache that affects all applications on the machine. To clear it, follow these steps:
- Press the Windows Key on your keyboard and type
cmd. - Right-click on Command Prompt and select Run as Administrator. This ensures you have the necessary permissions to modify system settings.
- In the black window that appears, type the following command exactly:
ipconfig /flushdns - Press Enter.
If successful, you will see a confirmation message stating: "Successfully flushed the DNS Resolver Cache."
How to Flush DNS on macOS
macOS handles DNS caching differently depending on the version of the OS. However, most modern versions of macOS (including Monterey, Ventura, and Sonoma) use a similar command structure through the Terminal.
- Open Finder, go to Applications, then Utilities, and launch the Terminal app.
- Type the following command:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder - Press Enter.
- The Terminal will prompt you for your administrator password. Type it in (note that the cursor will not move as you type for security reasons) and press Enter again.
There is no visual confirmation message on macOS; if the cursor returns to a new line without an error, the cache has been cleared.
Clearing DNS Cache in Web Browsers
Many modern browsers, particularly those based on Chromium (Google Chrome, Microsoft Edge, Brave), maintain their own internal DNS cache that is independent of the operating system. If you have flushed your system DNS but still cannot reach a site, you may need to clear the browser-level cache.
- Google Chrome: Type
chrome://net-internals/#dnsinto the address bar and press Enter. Click the Clear host cache button. - Microsoft Edge: Type
edge://net-internals/#dnsinto the address bar and click Clear host cache. - Mozilla Firefox: Firefox typically relies more heavily on the OS cache, but you can clear its internal cache by going to Settings > Privacy & Security > Cookies and Site Data > Clear Data.
When Should You Clear Your DNS Cache?
Flushing your DNS is a non-destructive process, but it is typically only necessary in specific troubleshooting scenarios. You should consider clearing your cache if you encounter the following:
- DNS Spoofing/Poisoning: If a malicious actor has corrupted your DNS cache to redirect you to a fraudulent website, flushing the cache removes the fake entry.
- Website Migration: When a site owner moves their website to a new hosting provider, the DNS records update globally. However, your local machine may hold the old record until the Time to Live (TTL) expires.
- Connectivity Errors: If you can access a website on your phone (using mobile data) but not on your computer (using the same network), a stale DNS cache is a likely culprit.
- Development Testing: Web developers frequently flush their DNS when updating
hostsfiles or changing DNS records to verify that changes are propagating correctly.
DNS Cache vs. Browser Cache
A common misconception is that clearing your browser's history or "cache" is the same as flushing the DNS. These are two entirely different functions:
- Browser Cache: Stores images, scripts, and HTML files from websites so the page loads faster the next time you visit. Clearing this removes the actual content of the page.
- DNS Cache: Stores the mapping of the domain name to the IP address. Clearing this only removes the "address book" entry, forcing the computer to ask the DNS server for the current IP address again.
Frequently Asked Questions
Will flushing my DNS delete my passwords or history?
No. Flushing the DNS cache only removes the temporary records of IP addresses associated with domain names. It does not affect your browsing history, saved passwords, cookies, or any personal data stored in your browser.
Is it safe to flush DNS frequently?
Yes, it is completely safe. The only downside is a negligible decrease in speed the first time you revisit a site, as your computer must perform a fresh DNS lookup instead of pulling the address from local memory.
Why am I still seeing the old site after flushing DNS?
If flushing the local cache doesn't work, the issue may be "upstream." Your Internet Service Provider (ISP) or your router may have its own DNS cache that is still holding the old record. In this case, you may need to restart your router or change your DNS provider to a public one like Google DNS or Cloudflare.
Do I need to restart my computer after flushing DNS?
No, a restart is not required. The changes take effect immediately. However, you should restart your web browser to ensure it recognizes the updated system records.
What is TTL in relation to DNS?
TTL stands for Time to Live. It is a setting in a DNS record that tells your computer how long to store the record in its cache before it must be refreshed. If a TTL is set to 3600 seconds, your computer will keep that IP address for one hour before asking the server for an update.