Every time you type a web address, your computer quietly asks a question: “What’s the IP address for this site?” The answer gets stored in a DNS cache, a small local memory that speeds up browsing by skipping repeat lookups. Most of the time this is invisible and helpful. But when a website moves to a new server, when you edit your hosts file, or when a stale record keeps sending you to the wrong place, that cached answer becomes the problem. (DNS Server overview)
Here’s the part that surprises people: the global DNS system handles billions of queries daily, and caching is the reason it doesn’t collapse under the load. Flushing your local cache is a safe, reversible troubleshooting step that takes seconds. This guide walks through the exact commands for each operating system, explains what flushing actually does and doesn’t fix, and covers the mistakes that trip people up.
What the DNS Cache Actually Does
When a browser resolves a domain, the answer passes through several layers. The operating system keeps a resolver cache so that the next request for the same domain returns instantly. Browsers often keep their own separate caches on top of that. Routers and your internet provider’s resolvers keep caches too.
Each record carries a TTL (time to live) value set by whoever owns the domain. A TTL of 300 seconds means resolvers may hold that answer for five minutes; a TTL of 86400 means a full day. The Domain Name System itself is defined in the foundational specifications, and TTL behavior is part of that design. In practice, this means a stale entry usually expires on its own. Flushing just forces the issue immediately.
Why bother? Common triggers include:
- A site migrated to new hosting and your machine still points at the old IP
- You edited the hosts file and the change isn’t taking effect
- Persistent “site can’t be reached” errors after a network change
- Suspicious redirects that suggest a poisoned or outdated cache entry
How to Flush DNS on Windows

Windows users have it easiest. The tool is built in and the command hasn’t changed in decades.
- Press the Windows key, type cmd, and right-click “Command Prompt” to choose Run as administrator.
- Type `ipconfig /flushdns` and press Enter.
- Look for the confirmation: “Successfully flushed the DNS Resolver Cache.”
That’s the whole procedure. To see what’s currently cached before you clear it, run `ipconfig /displaydns`. The output lists every record your machine is holding, which is genuinely useful when you want to confirm whether a stale entry exists.
A few practical notes from real-world use:
- The admin step matters. Running the command in a normal prompt often returns an error or silently does nothing useful.
- The hosts file lives at `C:WindowsSystem32driversetchosts`. Edits there may need a flush before they take effect, and the file sometimes needs to be opened in an editor with elevated permissions.
- Flushing is not the same as clearing browser data. If the problem is a corrupted site login or a broken page layout rather than name resolution, you likely need to clear browser cache and cookies instead. The two fixes solve different problems, and people routinely confuse them.
How to Flush DNS on macOS
Apple’s approach has shifted across versions, which is why advice found online often conflicts. The modern method (roughly macOS 10.11 and later, including current releases) uses two commands together:
- Open Terminal from Applications > Utilities.
- Run `sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder`
- Enter your admin password when prompted. No confirmation message appears, which unsettles first-timers. Silence means success.
The `mDNSResponder` process handles name resolution on macOS, and restarting it with the HUP signal forces it to drop cached entries. On older systems (around 10.7 through 10.10), `sudo killall -HUP mDNSResponder` alone was the standard. On even older versions, `dscacheutil -flushcache` by itself did the job. If you’re on a supported Mac, use the combined command and you’ll cover the bases.
One caveat worth stating plainly: Apple has never published a single canonical support page for this procedure, and the exact guidance has been inconsistent across releases. The combined command is the widely accepted approach, but verify against your specific macOS version if results seem off.
How to Flush DNS on Linux
Linux is the messiest case because there’s no single resolver. What you run depends on what’s installed.
| Setup | Command | Notes |
|---|---|---|
| systemd-resolved (most modern distros) | `sudo resolvectl flush-caches` | Current syntax on recent systemd versions |
| Older systemd-resolved | `sudo systemd-resolve –flush-caches` | Command was renamed around systemd v239 |
| nscd running | `sudo nscd -i hosts` | Invalidates the hosts cache only |
| Neither present | No action needed | Nothing is caching at that layer |
The trap here is assuming a flush worked when it didn’t. Many desktop Linux systems don’t run nscd at all, so `nscd -i hosts` is a no-op that returns without complaint. Check which services are active before trusting a command. Running `systemctl status systemd-resolved` tells you quickly whether the first option applies.
The Browser Has Its Own Cache
This is the single most common reason a flush “doesn’t work.” Chrome, Edge, and other Chromium browsers maintain an internal DNS cache that is entirely independent of the operating system’s. Clearing the OS cache leaves the browser’s copy untouched.
In Chrome, navigate to `chrome://net-internals/#dns` and click Clear host cache. Be aware that Google has altered and trimmed net-internals features over the years, so the exact layout may differ from older tutorials. If the page looks different than expected, that’s normal evolution, not a broken browser.
Firefox handles this differently and generally relies on the system resolver, so an OS-level flush usually suffices there. Safari follows the system as well on macOS.
The practical sequence when troubleshooting: flush the OS cache first, then the browser cache, then restart the browser. Doing it in the reverse order wastes time.
What Flushing Does Not Fix
Honesty matters here, because a lot of online advice overpromises. Flushing your local cache will not:
- Clear your ISP’s resolver cache. If your provider is holding a stale record, your local flush changes nothing. You wait for the TTL to expire or switch to a public resolver like Google Public DNS or Cloudflare’s 1.1.1.1.
- Clear your router’s cache. Many home routers cache DNS. A reboot clears it.
- Fix a misconfigured DNS record. If the domain owner published the wrong IP, no amount of local flushing helps.
- Solve general slowness. A slow connection is rarely a DNS cache problem.
Understanding the layered nature of DNS caching prevents hours of pointless troubleshooting. The cache hierarchy runs from browser to OS to router to ISP to authoritative servers, and a flush only touches one layer at a time. For broader connection problems, working through browser-level cleanup first is often the faster path, and a guide on how to clear browser cache and cookies covers the steps that resolve the majority of “website acting weird” complaints.
Common Mistakes and What Actually Works
After watching people struggle with this for years, certain patterns repeat.
Mistake one: skipping administrator rights. On Windows and macOS, the commands need elevation. Without it, you get an error or silence, and people assume the tool is broken.
Mistake two: expecting a confirmation message. Windows prints one. macOS and most Linux commands print nothing on success. Absence of output is the expected result, not a failure.
Mistake three: flushing once and declaring victory. If the upstream TTL is long, a single flush may not be enough because the resolver re-fetches the same stale answer. Flush, then check the actual resolved IP with `nslookup domain.com` or `dig domain.com` to confirm you’re getting the new address.
Mistake four: confusing DNS with the hosts file. If you added an entry to the hosts file and it isn’t working, the flush may be irrelevant; check the file’s syntax and permissions first.
Mistake five: ignoring IPv6. Some systems cache AAAA records separately in ways that behave unexpectedly. If IPv4 resolves correctly but the site still fails, test with `nslookup -type=AAAA domain.com`.
The reliable troubleshooting order is: confirm the DNS record is correct using a public lookup tool, flush the OS cache, clear the browser’s host cache, restart the browser, and only then consider router or ISP-level caching.
A Quick Decision Guide
Different symptoms point to different fixes. Use this as a starting map.
| Symptom | Likely cause | First action |
|---|---|---|
| Site moved hosts, old version loads | Stale OS cache | Flush OS DNS cache |
| Login broken, layout wrong | Browser data | Clear cookies and cache |
| Only one browser affected | Browser DNS cache | Clear browser host cache |
| Every device on network affected | Router or ISP cache | Reboot router, try public DNS |
| Intermittent failures across sites | Network or resolver issue | Test with `nslookup` |
This table won’t cover every scenario, but it eliminates the most frequent wrong turns.
Conclusion
Flushing the DNS cache is one of the few troubleshooting steps that is fast, free, reversible, and genuinely effective when applied to the right problem. The commands are short: `ipconfig /flushdns` on Windows, a two-part terminal command on macOS, and `resolvectl flush-caches` on most modern Linux systems. The skill isn’t memorizing syntax. It’s knowing that caches exist at multiple layers, that a flush only reaches one of them, and that browser-level caches sit outside the operating system’s control entirely.
Start local, work outward, and verify with a lookup command rather than assuming. That approach resolves the vast majority of stale-record headaches in under five minutes, and it keeps you from chasing problems that were never in the cache to begin with.
Frequently Asked Questions
Is it safe to flush the DNS cache?
Yes. Flushing is completely safe and reversible. It only removes stored lookup results, which your system rebuilds automatically on the next request. The only side effect is a brief moment of slightly slower resolution while the cache refills.
How often should I flush my DNS cache?
Only when you have a reason, such as a site that moved servers, a hosts file edit, or persistent connection errors. Routine flushing offers no benefit and slightly slows the first lookup afterward. There is no maintenance schedule worth following.
Why did my DNS flush not fix the problem?
The most likely reasons are an uncleared browser cache, a stale entry held by your router or internet provider, or a genuinely misconfigured DNS record. Run `nslookup` on the domain to see which IP you’re actually getting before assuming the flush failed.
Does flushing DNS delete my browsing history?
No. The DNS cache stores only domain-to-IP mappings, not the pages you visited. Your browsing history, cookies, and saved passwords are stored separately by the browser and are unaffected by a DNS flush.
Do I need to restart my computer after flushing DNS?
No restart is required. The change takes effect immediately. Restarting the browser is worth doing, though, because browsers keep independent caches that the operating system flush does not touch.
What is the difference between flushing DNS and clearing cookies?
Flushing DNS clears stored domain-to-IP address mappings at the operating system level. Clearing cookies removes website login and tracking data stored by the browser. DNS problems cause “site not found” errors; cookie problems cause login loops and broken page layouts.


