ipconfig.co.uk

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

Windows · Command Prompt
ipconfig /flushdns
Output
Windows 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:

Windows · PowerShell
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):

macOS · Terminal
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

There 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.

VersionCommand
macOS 10.15 to 26sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
macOS 10.11 to 10.14sudo killall -HUP mDNSResponder
OS X 10.10.4 and later 10.10sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
OS X 10.10 to 10.10.3sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches
OS X 10.7 to 10.9sudo killall -HUP mDNSResponder
OS X 10.5 and 10.6sudo dscacheutil -flushcache
Mac OS X 10.4 and earlierlookupd -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.

Linux · Terminal
sudo resolvectl flush-caches
resolvectl statistics                # cache size should now be 0
# older naming
sudo systemd-resolve --flush-caches

Ubuntu 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.

Applications 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

BrowserHow
Chrome, Chromium, Brave, Vivaldi, OperaVisit chrome://net-internals/#dns and click Clear host cache. Then chrome://net-internals/#socketsFlush socket pools to drop connections already open to the old server.
Edgeedge://net-internals/#dns › Clear host cache
FirefoxVisit about:networking#dns and click Clear DNS Cache. Alternatively restart Firefox; its cache expires after 60 seconds by default (network.dnsCacheExpiration in about:config).
SafariUses the macOS cache; flush that. Develop menu › Empty Caches clears page content, not DNS.
Any browser using DNS-over-HTTPSSecure 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

Windows · Command Prompt
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 resolver

A 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.

Related pages

Last reviewed . Command syntax verified against Windows 11, Ubuntu 24.04, macOS 15 and FreeBSD 14 unless noted otherwise.

Spotted a mistake or a switch we have missed? Every page on this site is written to be checked against real output, so please test on your own machine and compare.