DNS Cache Explained: How to Flush and Clear It

<span id="hs_cos_wrapper_name" class="hs_cos_wrapper hs_cos_wrapper_meta_field hs_cos_wrapper_type_text" style="" data-hs-cos-general-type="meta_field" data-hs-cos-type="text" >DNS Cache Explained: How to Flush and Clear It</span>

Your DNS cache holds every resolved record until its TTL (time to live) runs out. After a DNS or CDN change, you fix stale answers in two moves: flush each cache layer between you and the authoritative name server, then confirm that the answer you get matches the one that server publishes. On Windows the command is ipconfig /flushdns. On macOS it is sudo dscacheutil -flushcache followed by sudo killall -HUP mDNSResponder. On systemd Linux it is sudo resolvectl flush-caches. Plan on about 10 minutes for the full playbook, validation included.

As of 2026, the Windows DNS Client service caps positive cache entries at 86,400 seconds (one day) and negative answers at 900 seconds (15 minutes) by default, and every other layer applies its own limits on top. Flushing your machine clears only your local stub cache. Recursive resolvers keep serving the old record until the TTL they received from the authoritative server expires.

What the DNS cache stores and where it lives

A DNS cache stores resolved resource records (A, AAAA, CNAME, and so on) together with a countdown that starts at the record's TTL. It also stores negative answers. Per RFC 2308, an NXDOMAIN or empty answer is cached for the shorter of the SOA record's TTL and its minimum field. That is why a hostname you created five minutes ago can keep failing on a machine that queried it before it existed.

Between a browser tab and your authoritative zone there are usually four to six independent caches:

  • Application or runtime cache: browsers keep their own host cache, and the JVM caches lookups inside the process. Node.js and Go's pure resolver do not cache by default, so they lean on the OS.
  • OS stub resolver cache: the Windows DNS Client service, mDNSResponder on macOS, and systemd-resolved, nscd or dnsmasq on Linux.
  • Local network resolver: home routers, office forwarders, and Kubernetes CoreDNS with its cache plugin.
  • Recursive resolver: your ISP, corporate resolvers, or public services such as Google Public DNS and Cloudflare's 1.1.1.1.
  • Authoritative server: the source of truth. It caches nothing for your zone, but secondaries can lag on zone transfers.

TTL-respecting caches hand downstream the remaining TTL, not the original, so their staleness does not stack. Caches that impose a fixed hold time regardless of TTL do stack, and those are the ones that surprise people after a cutover.

How TTLs decide how long stale records survive

After a DNS change, worst-case staleness equals the old record's TTL at the recursive layer, plus any fixed-duration cache below it that grabbed the record just before expiry. A 300-second TTL with a browser that holds entries for 60 seconds gives a ceiling near 360 seconds, not 300.

The table below is this blog's staleness budget for a client behind a public recursive resolver, worked from documented defaults. Use it to predict how long you will wait if you do nothing, and which layer to flush to shorten that wait.

LayerHold behavior (defaults)Adds to staleness?Worst case with old TTL 300 s
Recursive resolverRespects TTL; some apply a minimum floorBase value300 s
OS stub (Windows, macOS, systemd-resolved)Respects remaining TTL; Windows caps at 86,400 sNo300 s
Firefox (native resolver)Fixed hold, network.dnsCacheExpiration default 60 sYes360 s
JVM (no security manager)Fixed 30 s unless networkaddress.cache.ttl is setYes330 s
Long-lived connections (HTTP/2 keep-alive, connection pools)No re-resolution until the connection closesYes, unboundedMinutes to hours

The longest tail after a DNS change usually comes from pooled connections that never re-resolve, not from any DNS cache, so restarting the client often matters more than flushing it.

How to flush DNS cache on Windows, macOS and Linux

Prerequisites

  • Admin rights on the machine: an elevated prompt on Windows, sudo on macOS and Linux.
  • The dig utility for validation (bundled on macOS and in bind-utils or dnsutils on Linux). On Windows, Resolve-DnsName in PowerShell does the same job.
  • The hostname you changed, written below as YOUR_HOSTNAME (for example, cdn.example.com), and the expected new value, written as EXPECTED_VALUE (the new CNAME target or IP).

Step 1: Confirm the authoritative answer first

Flushing is pointless if the authoritative server still publishes the old record. Find your zone's name servers with dig YOUR_HOSTNAME NS +short. If YOUR_HOSTNAME is not the zone apex, query the apex domain instead. Then ask one of them directly, with recursion off: dig @NS_HOSTNAME YOUR_HOSTNAME +norecurse +noall +answer, where NS_HOSTNAME is one of the name servers returned.

Why: if this answer is not EXPECTED_VALUE, the problem is your zone or a lagging secondary, and no flush will help. Query every listed name server, because a secondary that missed a zone transfer serves the old record to a share of resolvers.

Step 2: Clear DNS cache on Windows

From an elevated Command Prompt, run ipconfig /flushdns. In PowerShell, the equivalent is Clear-DnsClientCache. To inspect the cache before or after, run ipconfig /displaydns or Get-DnsClientCache -Entry YOUR_HOSTNAME.

Why: the DNS Client service caches positive answers for up to 86,400 seconds and negative answers for up to 900 seconds. The negative cache is the usual culprit when a brand-new hostname will not resolve. Entries from the hosts file show up in the cache too, and flushing does not remove them, so check that file if a stale value persists.

Step 3: Flush the DNS cache on macOS

Run sudo dscacheutil -flushcache, then sudo killall -HUP mDNSResponder. The second command does the real work on current macOS releases, because mDNSResponder owns the resolver cache. The HUP signal tells it to drop that cache without a restart.

Why both: dscacheutil clears the Directory Services cache, which some lookups still pass through. Running the pair costs nothing and covers every macOS version still in support.

Step 4: Clear DNS cache on Linux

Linux has no single cache, so first identify what is running. On systemd distributions, resolvectl status confirms systemd-resolved is active. Then flush with sudo resolvectl flush-caches and confirm with resolvectl statistics, where the current cache size should read zero.

For other stacks:

  • nscd: sudo nscd -i hosts invalidates the hosts table.
  • dnsmasq: sudo pkill -HUP dnsmasq clears its cache, and sudo systemctl restart dnsmasq also works.
  • Unbound (local or on your resolver): sudo unbound-control flush YOUR_HOSTNAME, or sudo unbound-control flush_zone example.com for a whole zone.
  • BIND recursive servers: sudo rndc flushname YOUR_HOSTNAME.

Why: many minimal server images run no local cache at all, so every lookup goes straight to the recursive resolver. If none of the above is running, there is nothing local to flush.

Step 5: How to clear DNS cache in Chrome, Firefox and Safari

Chrome and Edge keep a host cache separate from the OS. Open chrome://net-internals/#dns (or edge://net-internals/#dns) and click "Clear host cache". Then go to the Sockets page on the same tool and click "Flush socket pools", so existing connections to the old IP are closed. Without that second click, the browser keeps using connections it already has open.

In Firefox, open about:networking#dns and click "Clear DNS Cache". Safari has no separate DNS cache and relies on mDNSResponder, so Step 3 covers it. Quit and relaunch Safari to drop pooled connections.

Step 6: Clear runtime and resolver caches

A JVM caches successful lookups for 30 seconds by default, or forever if a security manager is installed. The only way to clear that cache is a process restart. To bound it going forward, set networkaddress.cache.ttl to 60 in the JDK's java.security file.

For recursive resolvers you do not control, Google Public DNS and Cloudflare's 1.1.1.1 both provide a public cache purge page for a single name. ISP resolvers offer nothing comparable, so they simply wait out the TTL.

Validate the change after a DNS cache clear

Run dig YOUR_HOSTNAME +noall +answer twice, a few seconds apart. The second column is the remaining TTL. If it decreases between runs, you are reading from a cache. If it equals the full TTL from Step 1 and the value is EXPECTED_VALUE, the recursive layer has fresh data.

To compare resolvers, run dig @1.1.1.1 YOUR_HOSTNAME +noall +answer and dig @8.8.8.8 YOUR_HOSTNAME +noall +answer. On Windows, run Resolve-DnsName YOUR_HOSTNAME -Server 1.1.1.1. To confirm traffic actually reaches the new CDN, open browser developer tools, reload with the cache disabled, and check the remote address and any provider-specific response headers on the asset request.

Rollback after a bad DNS or CDN change

Rolling back is the same change in reverse, and it is bound by the same TTL. If you raised the TTL as part of the change, every resolver that cached the bad record holds it for that full duration. That is why the TTL stays low until the new state is proven.

Revert the record at the authoritative server, re-run Step 1 against every name server, then flush the layers you control. For internal clients, flush the forwarders and recursive servers you operate (Unbound or BIND, as in Step 4) before touching any endpoint. One recursive flush fixes every client behind it.

Failure modes: symptom, cause, fix

  • Symptom: the new hostname returns NXDOMAIN on one machine only. Cause: a negative cache entry from a query made before the record existed. Fix: flush the OS cache. If the failure is resolver-wide, wait out the SOA minimum or purge at the public resolver.
  • Symptom: dig shows the new IP, but the browser still hits the old CDN. Cause: browser host cache or pooled HTTP/2 connections. Fix: clear the host cache and flush socket pools (Step 5), or restart the browser.
  • Symptom: services still call the old endpoint hours after the change. Cause: a JVM with a security manager caching forever, or connection pools with no maximum lifetime. Fix: roll-restart the service, then set networkaddress.cache.ttl and a pool connection max-age.
  • Symptom: some users get the old record, others the new one. Cause: a lagging secondary authoritative server, or ISP resolvers enforcing a minimum TTL floor. Fix: query every name server directly, and check the zone serial on each.
  • Symptom: flushing has no effect at all. Cause: a hosts file entry, or a VPN pushing its own resolver. Fix: check the hosts file, and confirm which server answers with resolvectl status or ipconfig /all.

Tuning TTLs before your next CDN cutover

The cheapest flush is the one you never need. A proven sequence: at least one old-TTL period before the change, drop the record's TTL to 60 seconds. With a 3,600-second TTL, do this an hour or more ahead. With 86,400 seconds, a full day ahead. Make the change, verify it, then raise the TTL back to 300 to 3,600 seconds once the new state has held through your peak traffic.

The trade-off is real. A 60-second TTL multiplies query volume to your authoritative provider and adds a resolver round trip for more users, typically tens of milliseconds on a cache miss. It also makes you more exposed to an authoritative outage, because resolvers run out of cached answers within a minute. Keep low TTLs for the change window, not as a permanent setting.

For CDN migrations specifically, a weighted DNS split avoids an all-at-once cutover: shift 5, then 25, then 100 percent of resolutions while caches drain. BlazingCDN can run as a second CDN behind DNS with a weighted traffic split, which is the setup described on its multi-CDN integration page.

FAQ: flushing and clearing the DNS cache

Does flushing the DNS cache change what other users see?

No, flushing the DNS cache on your machine affects only your own stub resolver and browser. Other users keep receiving whatever their recursive resolver has cached until the TTL it received from the authoritative server expires. To influence many clients at once, flush a recursive resolver you operate, or use the public purge pages offered by Google Public DNS and Cloudflare's 1.1.1.1.

Does a DNS cache clear affect other users on my network?

A DNS cache clear on one laptop does not affect anyone else on the same network. Shared caches live on the router, the office forwarder or the recursive resolver, and each must be flushed separately. On a home router, a reboot usually clears its forwarder cache. On Unbound or BIND, use unbound-control flush or rndc flushname for the specific hostname.

How long does a DNS change take to reach everyone without a flush?

Without a flush, a DNS change reaches everyone after roughly the old record's TTL, plus any fixed-duration cache below the resolver. With a 300-second TTL, expect about 5 to 6 minutes for browsers. Some ISP resolvers enforce minimum TTL floors, and long-lived HTTP connections can keep traffic on the old IP until they close, which stretches the tail further.

Why does Chrome ignore my DNS cache flush on Windows?

Chrome keeps its own host cache and pooled connections, so running ipconfig /flushdns alone does not reset it. Open chrome://net-internals/#dns and clear the host cache, then flush socket pools on the Sockets page. Existing HTTP/2 connections stay pinned to the old IP until they close, which is why a browser restart often appears to fix the problem.

Measure your own DNS staleness budget before the next cutover

This week, pick one non-critical hostname, lower its TTL to 60 seconds, and change its target. Then time three things: when dig against two public resolvers returns the new value, when a fresh browser profile reaches it, and when your longest-running service stops calling the old endpoint. The gap between the first and last numbers is your real staleness budget. It also points at the connection pools and runtime caches that need a max-age before any production DNS or CDN migration.

If that cutover moves heavy video, software or file traffic to a new delivery layer, the BlazingCDN features page lists what every plan includes, from origin shield and purge to Prometheus metrics: BlazingCDN delivery features for DNS-based migrations.

Heavy traffic.
Light bill.

The CDN for video and large traffic