Cloud VPS from $1.98/mo · pay with Bitcoin, Ethereum, Monero, USDT or Solana · paid in crypto
Networking

Flush the DNS cache on Windows, macOS, Linux and browsers

Flush DNS caches on Windows 11, macOS, Linux, Chrome, Edge and Firefox, find which layer still holds a stale record, and plan DNS changes so nobody needs to.

CloudSat teamNovember 18, 20266 min read
Abstract illustration of stacked translucent layers holding glowing address tags, one layer being swept clean
On this pageQuick reference

You moved a site to a new server, updated the DNS record, and your browser still opens the old one. Somewhere between you and the authoritative name server, a cache is still holding the previous answer, and it will keep doing so until the record's TTL runs out. Flushing helps, but only if you flush the layer that actually holds the stale record. This guide shows how to find that layer, the exact commands for each system, and how to plan DNS changes so that nobody has to flush anything.

Quick reference

Where Command or action
Windows 11, Windows Server ipconfig /flushdns or Clear-DnsClientCache
macOS sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Linux with systemd-resolved sudo resolvectl flush-caches
Chrome chrome://net-internals/#dns, then Clear host cache
Edge edge://net-internals/#dns, then Clear host cache
Firefox about:networking#dns, then Clear DNS Cache

The sections below explain when each one is the right fix, and what to check when it is not.

Where DNS answers are cached

Layer Examples Can you flush it?
Browser Chrome, Edge and Firefox keep their own host cache Yes, from an internal page
Operating system Windows DNS Client, macOS mDNSResponder, Linux systemd-resolved Yes, one command
Local resolver dnsmasq, Unbound, BIND, Pi-hole, your router Yes, if you administer it
Recursive resolver Your ISP, or public resolvers such as 1.1.1.1 and 8.8.8.8 Not directly; Cloudflare and Google publish cache-purge pages

Each layer may hold an answer for up to the TTL the authoritative server set. A record with a TTL of 86,400 seconds can stay stale in some caches for a full day after you change it.

First, check whether a cache is the problem

Ask the authoritative servers directly, then compare with what your own resolver returns. If they differ, a cache is involved. If they match, the problem is elsewhere.

dig +short NS example.com
dig +short app.example.com @ns1.your-dns-host.example
dig +short app.example.com
dig +short app.example.com @1.1.1.1

The first line finds the authoritative servers, the second asks one of them, and the last two show what your resolver and a public resolver currently believe. Without +short, dig also prints the remaining TTL in the answer section, which tells you how long a stale record will survive. On Windows, Resolve-DnsName app.example.com -Server 1.1.1.1 -DnsOnly does the same job.

Windows 11 and Windows Server

Open a terminal and clear the DNS Client cache with either command:

ipconfig /flushdns
Clear-DnsClientCache

To see what is cached before you flush, filter the cache for your domain:

Get-DnsClientCache | Where-Object Entry -like "*example.com*"

Entries from the hosts file in C:\Windows\System32\drivers\etc are loaded into the same cache and come back after every flush. If a name stubbornly resolves to an old address, check that file first. On a Windows Server running the DNS Server role, the server's own resolver cache is separate: clear it with Clear-DnsServerCache.

macOS

One line covers current macOS releases. It clears the directory services cache and tells the system resolver, mDNSResponder, to drop its records:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

The command prints nothing on success. Test again with dig or by reloading the page.

Linux desktops and servers

First find out what resolves names on the machine. Many minimal servers have no local cache at all: /etc/resolv.conf points straight at an upstream resolver, and there is nothing to flush.

resolvectl status
cat /etc/resolv.conf

A nameserver 127.0.0.53 line means systemd-resolved is caching. Flush it and confirm the cache is empty:

sudo resolvectl flush-caches
resolvectl statistics

For other local resolvers, use the command that matches:

Resolver Flush command
systemd-resolved sudo resolvectl flush-caches
nscd sudo nscd -i hosts
dnsmasq sudo systemctl restart dnsmasq (a SIGHUP also clears its cache)
Unbound sudo unbound-control flush app.example.com, or flush_zone example.com for a whole zone
BIND sudo rndc flushname app.example.com, or sudo rndc flush for everything

Flushing one name is kinder than flushing everything on a busy resolver, because a full flush sends a burst of fresh queries upstream.

Browsers

Browsers keep a small host cache of their own and, more importantly, keep connections open to the old address.

  • Chrome: open chrome://net-internals/#dns and click Clear host cache, then open chrome://net-internals/#sockets and click Flush socket pools.
  • Edge: the same pages under edge://net-internals/.
  • Firefox: open about:networking#dns and click Clear DNS Cache.

If secure DNS (DNS over HTTPS) is turned on in the browser, it does not use the operating system's resolver at all. That is why a terminal and a browser on the same machine can disagree. Check the setting under the browser's privacy or security options before you chase the wrong cache.

Phones and routers

On Android and iOS, toggling airplane mode on and off drops the resolver state; restarting the device is the fallback. Check whether Android's Private DNS setting sends queries to a specific provider. Home and office routers usually run a caching resolver too. Rebooting clears it, and many routers offer a flush in their admin page. On MikroTik RouterOS it is /ip dns cache flush, covered with the rest of the setup in configuring DNS on RouterOS 7.

When you are the one changing DNS

The best flush is the one nobody needs. Before moving a site or a mail server:

  1. Lower the TTL in advance. Drop it to 300 seconds at least one old-TTL period before the move, so every cache has picked up the short value by moving day.
  2. Change the record, then keep the old server answering until the previous TTL has passed. Visitors with stale caches still reach a working site.
  3. Raise the TTL again once traffic has moved, to cut query volume.

Watch out for negative caching too. If anyone queried a name before you created it, resolvers may remember "does not exist" for the negative-caching time set in the zone's SOA record. Create records before you announce them.

If you run your own caching resolver, for example Technitium DNS Server as a one-click app on CloudSat, you add one more cache to flush but gain a dashboard that shows exactly what it holds.

FAQ

Is flushing the DNS cache safe?

Yes. It only forces fresh lookups. The next request for each name takes slightly longer while the answer is fetched again, and nothing else changes.

I flushed everything and still see the old site. Why?

Check the browser's HTTP cache and open connections, any CDN in front of the site, the hosts file, and whether the upstream resolver still holds the old record. Comparing answers with dig @server usually shows which one.

How long does DNS propagation take?

There is no propagation as such, only cache expiry. Once the authoritative servers have the new record, caches pick it up as their copy of the old record expires, so the old TTL is the number to watch. Allow some margin: a few resolvers enforce their own minimum TTL, and some keep serving a stale answer when they cannot reach the authoritative servers.

Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.