Flush the DNS cache on Windows, Linux and macOS
- tool
- DNS
- versions
- Windows 10/11, Windows Server, systemd 239+ (resolvectl)
- os
- linux, macos, windows
To flush the DNS cache, run ipconfig /flushdns on Windows, resolvectl flush-caches on Linux systems that use systemd-resolved, and sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder on macOS. This discards the answers your machine has cached, including negative answers ("this name does not exist"), so the next lookup asks the configured DNS server again. It does not change what that server returns.
Windows
ipconfig /flushdns
ipconfig /displaydnsPer the Microsoft documentation, /flushdns "flushes and resets the contents of the DNS client resolver cache", including negative cache entries. /displaydns shows what is in the cache, which includes entries preloaded from the hosts file (C:\Windows\System32\drivers\etc\hosts).
Linux
resolvectl flush-caches # systemd-resolved (Ubuntu, Fedora, Debian with resolved)
resolvectl statistics # cache size and hit/miss countersThe resolvectl manual describes flush-caches as flushing all resource record caches the service keeps locally, mostly equivalent to sending SIGUSR2 to systemd-resolved, and notes that it requires root. Older systems used systemd-resolve --flush-caches. If your machine does not run systemd-resolved, there may be no local cache at all (glibc does not cache by itself), or the cache belongs to a daemon such as nscd, dnsmasq or unbound, which you restart or flush with its own tool.
macOS
sudo dscacheutil -flushcache
sudo killall -HUP mDNSRespondermDNSResponder is the macOS resolver daemon; sending it HUP makes it drop its cache.
Which cache answered?
| Cache | How to clear it |
|---|---|
| Operating system resolver | The commands above. |
| Browser (Chrome, Edge) | chrome://net-internals/#dns and "Clear host cache", or restart the browser. |
| hosts file | Not a cache: edit the file. Its entries win over DNS until you remove them. |
| Home router | Reboot it, or wait for the TTL. |
| ISP or public resolver | Wait for the TTL; some public resolvers offer a purge form. |
| Application (Java, Node.js process) | Restart the process; the JVM caches lookups itself. |
When it helps
Flush after you changed a record and your machine still uses the old address, or after a lookup failed (for example DNS_PROBE_FINISHED_NXDOMAIN or getaddrinfo ENOTFOUND) and the name now exists. Negative answers are cached too, for the time set by the zone's SOA record (RFC 2308), so a name created after a failed lookup can stay "missing" until you flush.
To confirm it worked, look the name up again (nslookup NAME on Windows, resolvectl query NAME on Linux) and compare the address with the authoritative answer described in checking DNS propagation.
FAQ
Does flushing the DNS cache make a new record visible everywhere?
No. It clears only the cache on your machine. Your router, your ISP resolver and public resolvers keep their copies until the record's TTL runs out, so other people may still see the old answer.
Why does the old IP address come back after I flushed the cache?
Something else still answers with it: an entry in the hosts file (it is preloaded into the Windows cache and survives /flushdns), a browser's own cache, or an upstream resolver that has not expired the record yet.
Do I need administrator rights?
On Linux, resolvectl flush-caches requires root, as its manual states, and the macOS commands run with sudo. If ipconfig /flushdns reports an error on Windows, run it again from a Command Prompt opened as administrator.