Flush the DNS cache on every platform
Your computer remembers DNS answers so it does not have to ask again. When a site moves, a hosts entry changes, or a resolver returned a bad answer, that memory is the problem. Here is how to clear it everywhere it hides.
When flushing helps, and when it does not
Flushing helps when the cached answer is wrong or stale: a website changed hosting and you still get the old server; you edited the hosts file; a DNS outage left negative answers ("name does not exist") in the cache; a VPN left records pointing at internal addresses. It does not help when the DNS server itself is returning the wrong answer, because the next lookup fetches the same thing. Test that first: nslookup example.com 1.1.1.1 against a public resolver and compare with your own. If they differ, the fix is on the resolver (or your router), not the cache.
Caches exist in several layers, and you may need to clear more than one: operating system → browser → router/ISP resolver. Each is covered below.
Windows
ipconfig /flushdnsWindows IP Configuration
Successfully flushed the DNS Resolver Cache.Works on every Windows since 2000; no administrator rights are needed on a normal machine. PowerShell equivalent:
Clear-DnsClientCache
Get-DnsClientCache # verify it is empty (hosts-file entries reappear immediately; that is expected)If it fails with Could not flush the DNS Resolver Cache: Function failed during execution, the DNS Client service is disabled. Re-enable it in the registry (HKLM\SYSTEM\CurrentControlSet\Services\Dnscache, Start = 2) and reboot; Windows 10 and 11 hide this service from services.msc. Also run ipconfig /registerdns if the stale record is your own machine's name on a domain.
Windows also caches negative answers for up to 15 minutes. ipconfig /displaydns shows them as Name does not exist; the flush removes them.
macOS
The command has changed with almost every release, which is why search results disagree. For all current versions (10.15 Catalina through macOS 15 Sequoia and 26 Tahoe):
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponderThere is no confirmation message; the prompt simply returns. To be sure it worked, run sudo killall -INFO mDNSResponder then look in Console for the cache statistics, or just test a lookup.
| Version | Command |
|---|---|
| macOS 10.15 to 26 | sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder |
| macOS 10.11 to 10.14 | sudo killall -HUP mDNSResponder |
| OS X 10.10.4 and later 10.10 | sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder |
| OS X 10.10 to 10.10.3 | sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches |
| OS X 10.7 to 10.9 | sudo killall -HUP mDNSResponder |
| OS X 10.5 and 10.6 | sudo dscacheutil -flushcache |
| Mac OS X 10.4 and earlier | lookupd -flushcache |
Safari uses the system cache, so this covers it. Chrome and Firefox on macOS have their own; see browsers.
Linux
Whether there is anything to flush depends on which resolver is running. Plain /etc/resolv.conf pointing at your router means the system keeps no cache at all; the router does.
sudo resolvectl flush-caches
resolvectl statistics # cache size should now be 0
# older naming
sudo systemd-resolve --flush-cachesUbuntu 18.04+, Fedora 33+, Arch (if enabled), Debian 12 desktop. Check with resolvectl status or ls -l /etc/resolv.conf pointing at /run/systemd/resolve/stub-resolv.conf.
sudo nscd -i hosts
# or
sudo systemctl restart nscdOlder RHEL, SUSE and some Debian installs.
sudo systemctl restart dnsmasq
# or send SIGHUP, which clears the cache and re-reads /etc/hosts
sudo pkill -HUP dnsmasqCommon on routers, Pi-hole, older Ubuntu desktops and libvirt networks.
sudo rndc flush # BIND: everything
sudo rndc flushname example.com # one name
sudo unbound-control flush example.com
sudo unbound-control flush_zone example.com
sudo unbound-control reload# NetworkManager itself does not cache, but it may run dnsmasq or systemd-resolved for you:
grep -r dns= /etc/NetworkManager/NetworkManager.conf /etc/NetworkManager/conf.d/
sudo systemctl restart NetworkManagerApplications with their own caches: Java (the JVM caches successful lookups forever by default unless networkaddress.cache.ttl is set), Nginx (resolves upstream names at start; reload it), Docker's embedded DNS (restart the container), and Chrome (below).
BSD
FreeBSD and OpenBSD have no system-wide cache unless you run local-unbound (FreeBSD: sudo service local_unbound restart) or unwind (OpenBSD: sudo rcctl restart unwind). Otherwise the router or upstream resolver holds the cache.
Browsers
| Browser | How |
|---|---|
| Chrome, Chromium, Brave, Vivaldi, Opera | Visit chrome://net-internals/#dns and click Clear host cache. Then chrome://net-internals/#sockets › Flush socket pools to drop connections already open to the old server. |
| Edge | edge://net-internals/#dns › Clear host cache |
| Firefox | Visit about:networking#dns and click Clear DNS Cache. Alternatively restart Firefox; its cache expires after 60 seconds by default (network.dnsCacheExpiration in about:config). |
| Safari | Uses the macOS cache; flush that. Develop menu › Empty Caches clears page content, not DNS. |
| Any browser using DNS-over-HTTPS | Secure DNS in the browser bypasses the OS cache entirely. Clearing the OS cache changes nothing; clear the browser cache, or turn Secure DNS off in the browser settings while testing. |
Routers and upstream resolvers
Home routers run a forwarder (usually dnsmasq) that caches for every device on your LAN. If flushing your computer does not help but nslookup example.com 1.1.1.1 gives a different answer from nslookup example.com 192.168.1.1, the router's cache is stale. Reboot it, or look for a "DNS cache" or "Diagnostics" page. Pi-hole: pihole restartdns. OpenWrt: /etc/init.d/dnsmasq restart. Beyond your router, your ISP's resolvers and public resolvers cache too: Google offers a purge form at developers.google.com/speed/public-dns/cache and Cloudflare at 1.1.1.1/purge-cache/. Their caches expire according to the record's TTL, which is why DNS changes are said to "take up to 48 hours": the old TTL may have been that long.
Verify the flush
ipconfig /displaydns | findstr /i example.com # should be gone
nslookup example.com # fresh lookup
nslookup example.com 1.1.1.1 # compare with a public resolverdig example.com +short
dig @1.1.1.1 example.com +short
dig example.com | grep -E '^example.com' # the TTL column drops as the cache ages; a fresh lookup shows the full TTL
resolvectl statistics # Linux: Current Cache SizeA TTL that starts at the record's full value (for example 300 or 3600) confirms the answer came fresh from the authoritative server rather than a cache.