
How to flush the DNS cache on Windows, Mac, Linux and browsers?
To flush the DNS cache, run ipconfig /flushdns in an administrator Command Prompt on Windows, sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder in Terminal on macOS, and resolvectl flush-caches on most modern Linux distributions. Chrome and Edge keep a separate cache that you clear at chrome://net-internals/#dns or edge://net-internals/#dns, and Firefox has a Clear DNS Cache button at about:networking#dns. Flushing removes stored DNS answers so the next lookup fetches fresh records.
DNS answers are cached in several places between you and a website, and flushing only one of them doesn't always help. This guide gives you the exact command for each operating system and browser, explains how to view the cache before and after, covers phones, local resolvers such as Unbound and dnsmasq, and shows how to ask Google and Cloudflare to drop their cached copy of your domain. It also explains when flushing won't make any difference, which saves you from running the same command over and over.
Where DNS Answers Are Cached
A single page load can involve several layers of caching:
- The browser: Chrome, Edge and Firefox keep their own short-lived DNS cache.
- The operating system: Windows, macOS and most Linux systems cache answers for all apps.
- The router: Most home routers run a small caching DNS forwarder.
- The recursive resolver: Your ISP's resolver, or a public one such as 1.1.1.1 or 8.8.8.8, caches answers for the record's TTL (time to live).
You can only flush the first two directly from your own device. You can restart a router to clear its cache, and some public resolvers let you request a purge for a specific name. Your ISP's resolver will simply keep its copy until the TTL runs out.
Windows
Flush the Cache
Open Command Prompt or PowerShell as administrator (right-click and choose Run as administrator) and run:
ipconfig /flushdns
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
In PowerShell, there's also a dedicated cmdlet that does the same thing:
Clear-DnsClientCache
This works on Windows 10, Windows 11 and Windows Server.
View the Cache
To see what's cached before or after flushing:
ipconfig /displaydns
The output is long. PowerShell gives you a filterable version:
Get-DnsClientCache | Where-Object Entry -like "*example.com*" |
Select-Object Entry, RecordName, Data, TimeToLive
Entry RecordName Data TimeToLive
----- ---------- ---- ----------
www.example.com www.example.com 192.0.2.10 2841
Entries loaded from the hosts file also appear in this cache. Flushing doesn't remove them, because Windows reloads them from the file straight away.
macOS
On current versions of macOS, open Terminal and run:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Enter your password when prompted. There's no confirmation message. If the command returns to the prompt without an error, it worked.
The first part clears the Directory Services cache, and the second tells mDNSResponder, the process that handles DNS on macOS, to drop its cache. This combined command has worked on every macOS release for many years, so it's the one to use whichever version you're running.
To check what the system resolver now returns for a name, use:
dscacheutil -q host -a name www.example.com
Linux
Linux doesn't have one universal DNS cache. What you need to flush depends on which service your distribution uses. Find out first:
ls -l /etc/resolv.conf
cat /etc/resolv.conf
nameserver 127.0.0.53with a symlink to/run/systemd/resolve/...: You're using systemd-resolved.nameserver 127.0.0.1: A local resolver such as dnsmasq, Unbound or BIND is likely running.- Any other address: There may be no local cache at all, in which case there's nothing to flush on the machine.
systemd-resolved
This covers Ubuntu, Fedora, Debian with systemd-resolved installed, and many others:
resolvectl flush-caches
Check the cache statistics to confirm it worked. The Current Cache Size should drop to zero:
resolvectl statistics
Transactions
Current Transactions: 0
Total Transactions: 1532
Cache
Current Cache Size: 0
Cache Hits: 611
Cache Misses: 921
On older systems, systemd-resolve --flush-caches does the same thing.
nscd
Some older or enterprise systems use the Name Service Cache Daemon. Invalidate its hosts cache with:
sudo nscd -i hosts
dnsmasq
dnsmasq clears its cache when it receives a SIGHUP signal, or you can simply restart it:
sudo pkill -HUP dnsmasq
# or
sudo systemctl restart dnsmasq
On desktop systems where NetworkManager runs its own dnsmasq instance, restart NetworkManager instead:
sudo systemctl restart NetworkManager
Local Recursive Resolvers
If you run your own resolver on a server or home lab, you can flush individual names rather than the whole cache, which is gentler on a busy system.
Unbound
# Flush one record type for a name
sudo unbound-control flush_type www.example.com A
# Flush the common record types for a name
sudo unbound-control flush www.example.com
# Flush a name and everything below it
sudo unbound-control flush_zone example.com
# Remove cached failures (SERVFAIL and similar) as well
sudo unbound-control flush_bogus
sudo unbound-control flush_negative
unbound-control only works when remote control is enabled with control-enable: yes in the remote-control: section of unbound.conf.
BIND
# Flush a single name
sudo rndc flushname www.example.com
# Flush a name and everything beneath it
sudo rndc flushtree example.com
# Flush the entire cache
sudo rndc flush
Pi-hole and AdGuard Home
Pi-hole uses its own build of dnsmasq. Restart its DNS service from the web interface (Settings > System > Restart DNS resolver, depending on your version) or with:
pihole restartdns
AdGuard Home has a Clear cache button in its DNS settings page.
Browsers
Chrome, Edge, Brave and Other Chromium Browsers
Chromium-based browsers have their own DNS cache that isn't cleared by flushing your operating system:
- Go to
chrome://net-internals/#dns(Edge:edge://net-internals/#dns, Brave:brave://net-internals/#dns). - Click Clear host cache.
- Go to
chrome://net-internals/#socketsand click Flush socket pools.
The socket step matters because open connections can keep using the old server's IP address even after the DNS cache is cleared. Reload the page afterwards.
Firefox
- Go to
about:networking#dns. - Click Clear DNS Cache.
This page also lists every cached name, its addresses, and whether it was resolved through Firefox's DNS over HTTPS (shown as TRR, short for Trusted Recursive Resolver).
Safari
Safari uses the macOS system resolver, so flushing macOS (as above) also clears Safari's DNS. Quitting and reopening Safari closes old connections.
Phones and Tablets
Android
There's no command to flush the system DNS cache on Android, but these approaches work:
- Toggle airplane mode on, wait a few seconds, then off.
- Turn Wi-Fi off and on, or forget and rejoin the network.
- Restart the phone, which clears everything.
- In Chrome for Android, visit
chrome://net-internals/#dnsand tap Clear host cache.
iPhone and iPad
- Toggle airplane mode on and off.
- Restart the device.
- If you use a DNS profile or a VPN app that provides DNS, disconnect and reconnect it.
Your Router
If every device on the network gets the same stale answer even after flushing, your router's cache is probably the cause. Restart the router. If you can log in to it, some models have a "clear DNS cache" option, but a restart works on all of them.
Public Resolvers
When you've just changed a DNS record and want people to see it sooner, the cached copy that matters most is on large public resolvers. Two of the biggest let you request a purge for a specific name:
- Google Public DNS: The Flush Cache page at
developers.google.com/speed/public-dns/cachelets you enter a domain and record type. - Cloudflare 1.1.1.1: The Purge Cache tool at
one.one.one.one/purge-cachedoes the same for Cloudflare's resolver.
These only affect those providers. Your ISP's resolver and any other resolver will keep the old answer until its TTL expires.
When Flushing Won't Help
Flushing removes cached answers on your side. It doesn't change what the authoritative nameservers are publishing. Before you flush again and again, check what the source actually says:
# Which nameservers are authoritative for the domain?
dig example.com NS +short
# What does one of them return right now?
dig @ns1.example.net www.example.com A +short
If the authoritative server still shows the old value, your change hasn't been saved, or it was made at a DNS provider your domain doesn't use. No amount of flushing will help until that's fixed.
Also check the TTL your resolver has left on its cached copy:
dig @1.1.1.1 www.example.com A +noall +answer
www.example.com. 1742 IN A 198.51.100.20
The second column is the remaining TTL in seconds. If it's large, the resolver will keep serving the cached answer for that long unless it's purged.
Finally, remember the hosts file. Entries in /etc/hosts or C:\Windows\System32\drivers\etc\hosts override DNS entirely, and no cache flush removes them.
Quick Reference
| Platform | Command or location |
|---|---|
| Windows | ipconfig /flushdns or Clear-DnsClientCache |
| macOS | sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder |
| Linux (systemd-resolved) | resolvectl flush-caches |
| Linux (nscd) | sudo nscd -i hosts |
| dnsmasq | sudo pkill -HUP dnsmasq |
| Unbound | sudo unbound-control flush_zone example.com |
| BIND | sudo rndc flushname www.example.com |
| Chrome / Edge | chrome://net-internals/#dns / edge://net-internals/#dns |
| Firefox | about:networking#dns |
| Android / iOS | Toggle airplane mode or restart |
| Google Public DNS | developers.google.com/speed/public-dns/cache |
| Cloudflare 1.1.1.1 | one.one.one.one/purge-cache |
FAQ: Flushing the DNS Cache
Yes. Flushing only removes stored lookups. Your device simply looks names up again the next time it needs them, which may make the first visit to each site a few milliseconds slower.
There's no need to do it routinely. Flush it when a website has moved to a new server, when you've just changed DNS records, or when you're troubleshooting resolution errors.
The old answer may still be cached in your browser, your router, or your ISP's resolver, or the authoritative nameservers may still be publishing the old record. Clear the browser's host cache, restart the router, and check the authoritative servers with dig.
On Windows, ipconfig /flushdns needs an elevated Command Prompt. On macOS and Linux, the commands need sudo, although resolvectl flush-caches may work without it depending on your system's policy.
No. The hosts file is read from disk and takes priority over DNS. To remove an override, edit the hosts file directly.
No. You can't clear another provider's resolver. You can switch your device to a public resolver, or use the purge tools offered by Google Public DNS and Cloudflare for their own caches.
Rarely. It helps when a cached answer is wrong or out of date, but it doesn't speed up a slow connection. If anything, the first lookups after a flush are marginally slower.
Conclusion
Flushing DNS is quick once you know which cache you're dealing with. On Windows use ipconfig /flushdns, on macOS the dscacheutil and mDNSResponder pair, and on most Linux systems resolvectl flush-caches. Then clear the browser's own cache, because Chrome, Edge and Firefox keep separate copies that the operating system flush doesn't touch.
If the old answer keeps coming back, stop flushing and check the source. Query the authoritative nameservers to confirm the record really changed, look at the remaining TTL on public resolvers, use the Google and Cloudflare purge tools if you need a faster update, and check the hosts file for overrides.


