DNS & Domain Names

How to Flush Your DNS Cache

Commands and steps to clear DNS caches on Windows, macOS, Linux, phones, browsers and routers, plus when it actually helps.

Key takeaways

  • DNS answers are cached in several places, including the browser, the operating system, the router and the resolver.
  • Flush the layer nearest you first, then work outward and check the answer directly at each step.
  • Flushing is harmless, and the only cost is that the next few lookups have to be fetched again.
  • If the authoritative server still returns the old data, no amount of flushing will change the result.

To flush the DNS cache on Windows, run ipconfig /flushdns. On macOS, run sudo dscacheutil -flushcache followed by sudo killall -HUP mDNSResponder. On Linux with systemd-resolved, run sudo resolvectl flush-caches. Browsers, routers and upstream resolvers keep their own caches, so you may need to clear more than one.

Flushing helps when your device remembers an old or wrong answer, such as just after a website has moved. It won't fix a broken connection, and it can't change what other people's computers have stored.

Why there is a cache at all

Looking up a name can take several round trips, as described in what happens during a DNS lookup. To avoid repeating that, each layer saves answers for a period set by the record's time to live, or TTL. Negative answers, such as "this name doesn't exist", are cached too. See DNS caching and TTL.

Places an old answer can hide
Browser Keeps its own short-lived lookups and open connections. Operating system A system-wide cache shared by applications. Router Many home routers cache and forward lookups. Recursive resolver Your provider's or a public service, shared by many users. Authoritative server The source of truth. Nothing to flush here. Browser Keeps its own short-lived lookups and open connections. Operating system A system-wide cache shared by applications. Router Many home routers cache and forward lookups. Recursive resolver Your provider's or a public service, shared by many users. Authoritative server The source of truth. Nothing to flush here.

Before you flush

Spend a few seconds confirming that a stale cache is the likely cause. Ask your normal resolver and then a different one for the same name. If they disagree, something is holding an old copy. If they agree, caching is probably not your problem.

It's also useful to note the current answer first, so you can tell whether anything changed. On a computer that other people manage, check that you're allowed to run administrative commands. Flushing is safe, but internal names fetched over a VPN may take a moment to resolve again afterward, and a few long-running programs hold on to addresses until you restart them.

Windows

Open Command Prompt or PowerShell and run:

ipconfig /flushdns

You should see a message saying the resolver cache was flushed. In PowerShell, you can also use:

Clear-DnsClientCache

If you get a permissions error, open the terminal as administrator. To see what's cached before or after:

ipconfig /displaydns
Get-DnsClientCache

The list can be long. Entries from the hosts file appear in it as well, and they return after a flush because they come from the file. See the hosts file.

macOS

Open Terminal and run:

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

Type your password when asked. Nothing is printed on success. mDNSResponder is the system service that handles name resolution, and the HUP signal tells it to reset its cache. These commands apply to current and recent versions of macOS. Much older releases used different ones.

Linux

Linux has no single DNS cache. It depends on what your distribution runs.

With systemd-resolved:

sudo resolvectl flush-caches
resolvectl statistics

The statistics output includes the current cache size, which should drop after flushing.

With other services:

Service How to clear it
nscd sudo nscd -i hosts
dnsmasq sudo systemctl restart dnsmasq
Unbound sudo unbound-control flush example.com
BIND as a resolver sudo rndc flush

If none is installed, there may be no local cache at all, and queries go straight to the resolver listed in your network settings. Containers and virtual machines can have their own resolver settings and caches, and restarting them is often the simplest reset.

Phones and tablets

Mobile systems don't offer a flush command. These actions usually clear the cached lookups:

  1. Turn airplane mode on, wait a few seconds and turn it off.
  2. Close and reopen the app or browser.
  3. Restart the device.

If a stale answer survives all three, it's probably coming from the router or resolver. Switching briefly from Wi-Fi to mobile data is a quick test, because it uses a different resolver.

Browsers

Chromium-based browsers such as Chrome and Edge have an internal page for networking. Enter chrome://net-internals/#dns (or the equivalent edge:// address) and choose to clear the host cache. Clearing socket pools from the same tool closes connections that are still open to the old server.

In Firefox, enter about:networking#dns and use the button to clear the DNS cache.

These internal pages change from time to time. Fully quitting and reopening the browser works as well. Be aware that a redirect cached by the browser looks like a DNS problem but isn't: test in a private window. Clearing cache and cookies covers that separate cache.

Routers and resolvers

For a home router, a restart normally empties its DNS cache. Some have a dedicated button in the administration pages.

You can't flush a provider's resolver. Some large public resolvers offer a web form that asks them to purge a particular name and record type. Otherwise you wait for the TTL to run out.

If you run your own network-wide resolver or blocker, restart it or use its flush option.

Check whether it worked

Don't rely on the browser. Ask each layer directly and compare.

nslookup example.com
nslookup example.com 1.1.1.1
dig example.com A
dig @1.1.1.1 example.com A

To see the source of truth, find the authoritative servers and query one:

dig example.com NS +short
dig @ns1.example.net example.com A

Use a name server from the first command's output in the second. The TTL shown by a caching resolver counts down on repeated queries, which tells you how long the old answer may last. Using nslookup and dig explains the output.

Still seeing the old answer?
Does the authoritative server return the old data? YES Fix the record at the DNS host. Flushing won't help. 1 NO Does a public resolver return the old data? YES Wait for the TTL, or use that service's purge form. 2 NO Does your router return the old data? YES Restart the router or flush it. 3 NO It's on your device Flush the system cache, restart the browser and check the hosts file. Does the authoritative server return the old data? 1 IF YES Fix the record at the DNS host. Flushing won't help. NO Does a public resolver return the old data? 2 IF YES Wait for the TTL, or use that service's purge form. NO Does your router return the old data? 3 IF YES Restart the router or flush it. NO It's on your device Flush the system cache, restart the browser and check the hosts file.

Note that dig and nslookup talk to a DNS server themselves and may skip parts of your operating system's cache. To see what applications will get on Windows, use Resolve-DnsName example.com or ping -n 1 example.com. On Linux, getent hosts example.com follows the system's normal lookup path.

Programs that cache on their own

Some software ignores all of the above because it stores addresses itself. If the system resolves a name correctly and one program still reaches the old server, suspect that program.

  • Long-running applications may resolve a name once at startup and reuse the result. Restart them.
  • Java applications have their own address cache, controlled by security properties. Restarting the process clears it.
  • Database and connection pools keep existing connections open, so they stay attached to the old server even after the name changes.
  • Proxies and load balancers may resolve backend names only when their configuration loads. Reload them.
  • VPN clients and security agents sometimes run a private resolver with its own cache. Disconnecting and reconnecting usually resets it.

A corporate proxy is a special case: your computer may never look up the name at all, leaving the proxy to do it. Flushing locally has no effect, and your IT team controls the cache that matters.

Negative caching

A common trap is checking for a new record a moment before you create it. The resolver receives "no such name" and remembers that, for a period derived from the zone's SOA record. You then add the record, and everyone else seems able to see it except you.

Flushing your device clears your local copy of the failure, but your resolver may still hold it. Query a resolver that hasn't been asked yet, or the authoritative server, to confirm the record is live, and then wait. The codes involved are described in NXDOMAIN and other DNS errors. The simplest prevention is to create records first and test them second.

When flushing helps and when it doesn't

It's worth trying when:

  • a site moved and you still reach the old server,
  • you looked up a new name before it was created and now get a cached "not found",
  • you changed DNS resolvers or left a VPN and internal names behave oddly,
  • you're testing your own record changes.

It won't help when the Wi-Fi or internet connection is down, the server itself is failing, a certificate has expired or the DNS records are simply wrong. For lookups that time out, see DNS server not responding.

If you manage the domain

Visitors can't be asked to flush their caches. Plan changes so they don't need to: reduce the TTL well before a move, keep the old server running while caches expire and verify the new records at the authoritative servers before announcing anything. The method is in lowering TTL before a cutover, and a TTL change planner can help you work out the timing.

Common questions

How often should I flush?

Only when you have a reason. Caches expire on their own, and routine flushing just makes lookups slightly slower.

Does flushing delete my history or passwords?

No. It removes only stored name-to-address answers. Browsing history, cookies and saved passwords are separate.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in DNS & Domain Names →

Latest news on this topic