Skip to content

DNS caching is one of those quiet features that makes the internet feel fast. Every time you open a page, your device has to turn a name into an address. If it had to ask the whole DNS system each time, pages would load more slowly and the DNS servers would carry far more traffic. So almost every layer, from the browser to your provider's resolver, remembers recent answers for a short while.

The side effect is that sometimes an answer is remembered for longer than it is correct. A site you just moved may still open at the old server, or a name you have just created may still return "not found" on your computer only. This guide explains where the cache lives, how long it keeps things, and how to clear each layer when you really need to. It is a practical companion to checking DNS from multiple countries and to the troubleshooting steps for DNS_PROBE_FINISHED_NXDOMAIN.

What a DNS cache is and why it exists

A DNS cache is a temporary table of answers. Each entry holds a name, the type of record asked for, the answer and a countdown. The countdown starts at the record's TTL (time to live), the number of seconds the owner of the zone says the answer may be reused. When it reaches zero the entry is thrown away and the next request triggers a fresh lookup. The behaviour is part of the original design, described in RFC 1034 and RFC 1035, and explained in plain language by Cloudflare Learning.

Caching serves three purposes: speed, because a local answer returns in a fraction of the time of a full lookup; load reduction, because millions of repeated questions do not reach the authoritative servers; and resilience, because a cached answer can keep working briefly if an upstream server is slow.

Caches also store negative answers. If a name did not exist when it was asked, the "no such name" result may be remembered, for a time taken from the zone's SOA record. That is why a hostname you created a minute ago may still look missing on one device.

The cache layers between you and the answer

A single page visit can pass through five caches. Knowing them tells you what to clear.

Layer Where it lives Typical way to clear it
Browser Inside the browser process Browser's internal DNS page, or restarting the browser
Operating system DNS client service on your computer A flush command for your OS
Router Small resolver inside a home or office router Restart the router
Provider or company resolver The recursive resolver your network uses Wait for the TTL, or switch resolver; you cannot clear it
Content or page cache CDN or browser page cache Hard reload, or purge at the CDN

The last row is not DNS, but people confuse it with DNS often. If the address is right but the content looks old, you may have a page cache problem, not a DNS one. The article on the difference between DNS and a CDN shows how to tell them apart.

When flushing helps

Flush when these are true together: you made a DNS change, you confirmed that the authoritative nameservers return the new value, and you still see the old behaviour on your device. Typical cases are:

  • A site you moved to a new server still opens the old version for you.
  • A new subdomain returns "site can't be reached" on your computer but works on your phone with mobile data.
  • You switched to different DNS servers and want to be sure nothing from the old resolver remains.
  • A development or staging name changed address and your tools keep contacting the old one.

Flushing does not help when the record itself is wrong, when the problem is on the domain side, or when the stale data lives in a cache you do not control. In those cases, check the authoritative answer first.

How to flush: step by step

Work from the closest layer outward and test after each step.

Step 1: the browser

Chrome and other Chromium-based browsers keep a host cache. Open chrome://net-internals/#dns and choose the option to clear the host cache. Also close and reopen the browser, because open connections can hold on to addresses. Other browsers keep an internal cache too, and restarting them clears it. If a page still looks old, try a hard reload (Ctrl+Shift+R, or Cmd+Shift+R on a Mac), which asks for the page again rather than using a stored copy.

Step 2: the operating system

Windows. Open Command Prompt and run:

ipconfig /flushdns

The system confirms that the DNS Resolver Cache was flushed. To view what is stored, ipconfig /displaydns lists entries. If you want to check the effect, run it before and after.

macOS. Open Terminal and run:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

You will be asked for your account password. This command has worked on current macOS versions; if a future version changes it, search the vendor's documentation for the current command.

Linux. The command depends on what handles DNS. On systems with systemd-resolved:

resolvectl flush-caches

On older setups the command may be sudo systemd-resolve --flush-caches. Systems running dnsmasq, nscd or a local BIND resolver have their own restart or flush command, for example sudo systemctl restart dnsmasq. Many Linux desktops have no OS-level cache at all, in which case there is nothing to clear.

Android and iOS. There is no simple flush command. Toggling airplane mode on and off, or restarting the device, clears the network stack's cached answers. On Android, Chrome's internal page can clear its own host cache too.

Step 3: the router

Restart the router by unplugging it for around 30 seconds, then plugging it back in. This clears its small DNS cache and renews the settings your provider hands out. Many routers also have a DNS or "network" page where you can see which DNS servers they use. Write them down before changing anything.

Step 4: the resolver you ask

You cannot flush your provider's resolver, but you can bypass it. Point your device to a different, reputable resolver, or ask one directly with dig example.com @resolver-address. Several large public resolvers also offer a web form to request a refresh of one name from their cache. Check your chosen resolver's documentation for it. If it works, the problem was only that resolver's cache.

Step 5: confirm

Run nslookup example.com or dig example.com and compare the answer with the authoritative one. When the two match, the cache is no longer the issue. If they still differ, wait for the TTL to run out, or look again at the layers above.

Reading TTL values in practice

You can see the cache at work with dig. Run dig example.com A twice a few seconds apart against the same recursive resolver. The first answer may show a TTL such as 300. The second, if the resolver served it from cache, shows a smaller number such as 287, because the countdown is still running. When it hits zero, the next query shows the full TTL again, which tells you the resolver just fetched a fresh copy.

This small experiment is useful in three ways. It proves whether the answer came from a cache at all, since an authoritative server always shows the full configured TTL. It tells you how long you would have to wait before a given resolver refreshes. And it shows which TTL values you should choose. A value of 300 to 900 seconds is common while you are working on a change, and a longer value such as an hour or more suits records that rarely change, because it reduces lookups. Choose the lower figure only for the period when you need fast changes.

Be aware of two details. First, some resolvers apply their own minimum or maximum, so a very small or very large TTL is not always followed exactly. Second, the TTL of a CNAME and of the record it points to are counted separately, so a chain of records can refresh at different moments. If a site depends on several linked names, check each one.

Preventing stale-cache problems

Most flush emergencies can be avoided with a little planning.

  1. Lower the TTL ahead of time. A day before a planned move, set the relevant records to a short TTL, wait for the old TTL to expire, then make the change.
  2. Keep the old server running for a while. After switching, leave the old server available for at least as long as the old TTL, so visitors on stale caches still reach a working site.
  3. Change one thing at a time. Moving the website, the nameservers and email in a single step makes it hard to see which cache is causing which symptom.
  4. Verify at the source. Query the authoritative nameserver before you test from a browser. It saves hours of flushing caches that were never the problem.
  5. Raise the TTL again. Once everything is stable, return to a longer TTL to reduce lookups and give a little protection if a nameserver is briefly unreachable.

A worked example

Lena moves her blog from an old host to a new one. She changes the A record to the new server address at 10:00. By 10:05 the authoritative nameserver returns the new address, which she verifies with dig against it.

At 10:10 her own laptop still opens the old blog. She follows the layers. She closes and reopens the browser: no change. She runs ipconfig /flushdns: no change. She runs nslookup blog.example and sees the old address, with the server line naming her router. She restarts the router, flushes again, and now the laptop shows the new address.

Her friend on a different provider still sees the old site until noon, because that provider's resolver cached the record with a long TTL before the change. Lena cannot flush that resolver; she can only wait for the TTL. Next time she will lower the TTL a day ahead of the move.

Limits and what to watch for

  • Flushing only affects your cache. It does not make other people see the change sooner. Visitors depend on their own resolvers and devices.
  • A low TTL is the best tool, and it must be set early. Lowering it at the moment you change the record does not help, because caches already hold copies made under the old TTL.
  • Do not flush as a ritual. If you flush repeatedly and nothing changes, the cached answer is probably correct, and the real fault is the record, the server or a CDN. Verify the authoritative answer instead of trying more flushes.
  • Commands change over time. Operating systems update their DNS services. If a command is not found, check the vendor documentation for your current version.
  • Administrator rights are needed. Flush commands on macOS and Linux need sudo. On a work computer, you may not have this permission and should ask the IT team.
  • A VPN or Proxy can have its own DNS settings. Some tools use their own resolver or cache. If you use one for work testing, check its documentation, and use it only within its terms and the law.
  • Do not flush in production scripts without need. Clearing the cache on a busy server increases load on its upstream resolver for a short while.
  • A flushed cache can still re-learn a stale answer. If the resolver you ask still holds the old value, it will hand it back to your freshly cleared cache.

Summary

A DNS cache stores recent answers so that pages open faster, and it keeps them for the TTL that the record's owner chose. Stale entries can sit in the browser, the operating system, the router and your provider's resolver. Clear them from the nearest layer outward: restart the browser, run the flush command for your OS, restart the router, and, if needed, switch the resolver. Always check the authoritative answer first, so that you do not flush a cache that is actually right. And plan changes by lowering the TTL a day ahead. If you manage names and records yourself, the domains page is a convenient place to start.

Frequently asked questions

What is a DNS cache?

It is a temporary store of recent DNS answers kept by your browser, operating system, router and your provider's resolver. It saves time because repeat visits do not need a fresh lookup.

When should I flush the DNS cache?

Flush it after a DNS change has been made and confirmed at the authoritative server, when a site opens an old version or shows a name-not-found error only on your device, or after changing DNS servers.

Is flushing the DNS cache safe?

Yes. It only removes stored answers. The next visit to each site performs a fresh lookup, which may be marginally slower once. It does not delete bookmarks, passwords or browsing data.

Why does the site still look old after I flush?

Several caches sit between you and the answer: browser, operating system, router and the provider's resolver. Flushing your own device does not clear the others, and the page itself may be cached by a CDN or the browser.

Does the TTL control how long a record stays cached?

Yes. The TTL in the DNS record tells caches how many seconds they may keep the answer. Most caches follow it, so a low TTL before a planned change shortens the wait.

About the author

Bob Kanokphon Thongdee, founder of XPASS VPN

Bob Kanokphon Thongdee

  • Founder of XPASS VPN
  • Co-founder of eSIMonline.asia
  • More than 7 years in online marketing
  • Founder of Cojourney Visa and Cojourney Travel

Ready to register your domain?

Search a name, compare extensions and pay once for the years you choose.

.com registration from $18.81 for the first year

Search domains

Keep reading

Domain & DNS Guides

How to Check DNS From Multiple Countries

A DNS change can look finished on your screen and still be wrong elsewhere. Here is how to check answers from several regions and how to interpret the differences.

10 min read

Domain & DNS Guides

DNS vs CDN: What Is the Difference?

DNS tells browsers where your site lives, while a CDN delivers copies of your content from nearby locations. Here is how the two fit together and where they differ.

9 min read

Domain & DNS Guides

How to Fix DNS_PROBE_FINISHED_NXDOMAIN

DNS_PROBE_FINISHED_NXDOMAIN means the name could not be resolved. Here is how to find out whether the fault is on your device or in the domain's DNS, and how to fix each case.

10 min read