Ever tried loading a site you just updated, only to see the old version staring back at you?
Also, you refresh, you clear cookies, you even reboot the router—still the same stale page. That’s the DNS cache pulling a fast‑one, and it happens more often than you think.
What Is a DNS Cache
Your computer, phone, and even your router keep a tiny phone‑book of domain names and the IP addresses they point to.
On the flip side, com**, the system asks “Hey, what’s the IP? ” If it already knows, it skips the lookup and uses the saved answer. When you type **example.That saved answer is the DNS cache.
Where It Lives
- Operating system – Windows, macOS, Linux each store their own cache.
- Web browsers – Chrome, Firefox, Edge keep a separate list just for the sites you visit.
- Router – Home routers often have a built‑in DNS forwarder that caches queries for every device on the network.
In practice, the cache is a speed‑boost. It saves you a round‑trip to your ISP’s DNS server, which can shave off a few milliseconds. But when a website changes its IP, the cache can become a roadblock Easy to understand, harder to ignore..
Why It Matters
Imagine you’re a developer pushing a new version of a web app. Practically speaking, the new code lives on a fresh server, but the old IP is still hanging around in your DNS cache. You’ll keep seeing the previous version, and you might think the deployment failed Still holds up..
Or you’re troubleshooting a “site can’t be reached” error. The real problem could be a corrupted DNS entry that’s stuck in your cache, not a broken server.
When you clear the cache, you force a fresh lookup. That’s why clearing DNS is a go‑to step for web developers, IT pros, and anyone who just wants the internet to behave Easy to understand, harder to ignore..
How It Works (or How to Do It)
Below are the most common places you’ll need to clear DNS and the exact steps to make it happen. Pick the one that matches your device.
Windows
-
Open Command Prompt – press
Win + R, typecmd, hit Enter. -
Run the flush command
ipconfig /flushdnsYou should see “Successfully flushed the DNS Resolver Cache.”
-
(Optional) Restart the DNS client service – if the flush didn’t work, type:
net stop dnscache net start dnscache
That’s it. Windows will now query the DNS server again the next time you visit a site Small thing, real impact. Worth knowing..
macOS
-
Open Terminal – find it in Applications → Utilities Most people skip this — try not to..
-
Enter the appropriate command – macOS changes the command slightly with each version. The most universal one works on macOS 10.10 and later:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder -
Enter your password when prompted. No confirmation message appears, but the cache is gone.
If you’re on an older macOS (like 10.9), replace the command with sudo discoveryutil mdnsflushcache.
Linux
Linux distributions differ, but the principle is the same: restart the caching service Worth keeping that in mind..
-
systemd‑resolved (Ubuntu 18.04+ and many others)
sudo systemd-resolve --flush-caches -
dnsmasq
sudo systemctl restart dnsmasq -
nscd (Name Service Cache Daemon)
sudo /etc/init.d/nscd restart
If you’re not sure which daemon you run, check ps aux | grep -E 'systemd-resolve|dnsmasq|nscd'.
Web Browsers
Even after you clear the OS cache, browsers keep their own entries.
Chrome / Edge / Brave
- Open a new tab and go to
chrome://net-internals/#dns. - Click Clear host cache.
(Edge uses the same edge://net-internals/#dns URL.)
Firefox
- Type
about:networking#dnsin the address bar. - Click Clear DNS Cache.
Safari
Safari relies on the macOS cache, so the Terminal command above does the trick. There’s no separate UI.
Router
Home routers often act as the first DNS resolver for every device. Flushing that cache can solve network‑wide issues.
- Log into your router’s admin panel (usually
192.168.1.1or192.168.0.1). - Look for a System or Advanced tab, then find Reboot or Clear DNS Cache.
- If there’s no explicit button, just power‑cycle the router: unplug, wait 10 seconds, plug back in.
Mobile Devices
Android
- Settings → Apps → Chrome (or your default browser) → Storage → Clear Cache.
- For the OS cache, enable Developer Options (tap Build number seven times), then go to Developer options → Reset Wi‑Fi, mobile & Bluetooth. That forces a DNS refresh.
iOS
- Settings → Safari → Clear History and Website Data clears Safari’s DNS entries.
- To flush the system cache, toggle Airplane Mode on for a few seconds, then off again. That forces iOS to redo DNS lookups.
Common Mistakes / What Most People Get Wrong
- Thinking “clearing cache” = “clearing cookies.” They’re different beasts. Cookies store login sessions; DNS cache stores IP lookups. Deleting cookies won’t fix a stale DNS entry.
- Skipping the browser cache. You flush the OS, but Chrome still shows the old IP because it cached the DNS record itself. Always clear the browser cache too.
- Rebooting the computer and assuming it’s enough. Some OSes keep the DNS cache alive across reboots, especially if a service like
systemd-resolvedrestarts automatically. Running the flush command is still required. - Forgetting the router. In a household with many devices, the router’s cache can override everything else. If one device works and another doesn’t, the router is the usual suspect.
- Using the wrong command for your OS version. macOS changed the flush command multiple times. Using an outdated command silently fails, leaving you puzzled.
Practical Tips / What Actually Works
-
Make a habit of a one‑liner script.
# Windows ipconfig /flushdns # macOS sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder # Linux (systemd-resolved) sudo systemd-resolve --flush-cachesSave it as
flushdns.bator a shell script and run it whenever you suspect stale DNS Not complicated — just consistent.. -
Use a public DNS service like Cloudflare (
1.1.1.1) or Google (8.8.8.8). They tend to have lower TTLs, meaning cached entries expire faster. Change it in your network adapter settings or router DHCP config It's one of those things that adds up.. -
Check the TTL (time‑to‑live) of a DNS record with
nslookupordig. If the TTL is high (e.g., 86400 seconds), the cache will stick around for a day unless you flush it manually. -
Automate router cache clearing if your firmware supports it. Some modern routers have an API you can call with a simple curl command.
-
When troubleshooting, combine tools. Run
ping example.comto see the IP your system resolves, thennslookup example.comto compare it with the authoritative DNS server. If they differ, you know the cache is stale.
FAQ
Q: Does clearing DNS affect my internet speed?
A: Only temporarily. The next lookup will be a bit slower because it has to query the upstream server, but the benefit is you get the correct IP. After the cache rebuilds, speed returns to normal.
Q: How often should I clear my DNS cache?
A: Not often. Only when you notice outdated content, connectivity glitches, or after a DNS record change. Frequent clearing isn’t necessary and can add needless latency That alone is useful..
Q: Can a malware infection hide in the DNS cache?
A: Malware can poison DNS entries, but the cache itself is just a storage of those entries. Flushing the cache removes the poisoned records, but you still need to clean the underlying infection.
Q: Will clearing DNS log me out of websites?
A: No. DNS deals only with translating domain names to IPs. Your authentication cookies remain untouched Which is the point..
Q: Is there a way to view what’s currently cached?
A: Yes.
- Windows:
ipconfig /displaydns - macOS:
sudo killall -INFO mDNSResponder(writes a log you can read) - Linux:
systemd-resolve --statisticsor check/var/cache/dnsmasq/if you use dnsmasq.
So the next time a site refuses to show its latest changes, or a “site can’t be reached” error pops up, remember the DNS cache is often the silent culprit. A quick flush—whether on your laptop, phone, or router—forces the internet to do a fresh lookup, and you’ll be back on track in seconds Worth knowing..
Happy browsing, and may your DNS always point the right way.