Skip to main content

Guides / Fix it: guides for the errors people actually hit

How to flush the DNS cache on Windows, macOS and Linux

To flush DNS, run ipconfig /flushdns on Windows, sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder on macOS, or resolvectl flush-caches on Linux with systemd-resolved. The exact command depends on your operating system and, on Linux, on which resolver it runs.

What the DNS cache is and why flushing helps

Every time a device resolves a hostname to an IP address, it saves the answer for a while instead of asking again on the next request. That saved answer lives in the operating system's DNS cache, and it is separate from the DNS cache your browser keeps on top of it. Caching is what makes browsing fast: without it, every request to every asset on a page would trigger a fresh lookup.

The cache becomes a problem the moment a record changes. If a site moved to a new IP address, switched hosting providers, or updated a CNAME, your machine can keep answering with the old value until the cached entry expires. Resolvers also cache negative answers, meaning "this name does not exist," for a period set by the domain's SOA record, so a name that just started working can still fail locally for several minutes. Flushing the cache forces the next lookup to go out fresh instead of reusing whatever was stored.

How to flush DNS on Windows

  1. Open Command Prompt. Microsoft's own troubleshooting steps use an elevated prompt (right-click, Run as administrator) for DNS commands, so start there if the plain version behaves oddly.
  2. Run ipconfig /flushdns. Per Microsoft Learn's documentation for the command, this "flushes and resets the contents of the DNS client resolver cache," discarding both negative entries and anything cached dynamically.
  3. Confirm it worked with ipconfig /displaydns, which lists everything currently in the resolver cache. Right after a flush this should return a near-empty list; browse to a couple of sites and run it again to see fresh entries repopulate.

If a stale address keeps coming back, the DHCP-assigned DNS servers themselves may be cached along with the lease. Releasing and renewing the adapter picks up both:

ipconfig /release
ipconfig /renew

How to flush DNS on macOS

The command depends on how old the machine's macOS version is, and using the wrong one for a modern Mac silently does nothing.

  • Yosemite 10.10.4 and every version since (this covers all currently supported macOS releases, including Sequoia, Sonoma, Ventura, Monterey and Big Sur): sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder. The first command clears the Directory Service cache; the second sends mDNSResponder a HUP signal so it restarts and drops what it was holding.
  • Yosemite 10.10 through 10.10.3 only used a different tool: sudo discoveryutil mdnsflushcache.
  • Mavericks, Mountain Lion and Lion: sudo killall -HUP mDNSResponder alone was enough.
  • Snow Leopard (10.6 to 10.6.8): sudo dscacheutil -flushcache alone, with no killall step.

Unless you are on a Mac old enough to predate 2014's Yosemite update, use the first command. Both parts require your account password, and the command produces no output on success.

How to flush DNS on Linux

Linux has no single DNS cache to flush, because distributions ship different resolver stacks. Check which one is active before picking a command.

Run resolvectl status first. If it returns per-interface DNS settings, the machine is running systemd-resolved, which is the default on current Ubuntu, Fedora and most other modern distributions. If the command is not found, check for the other two common services instead: systemctl status nscd or systemctl status dnsmasq (or, if systemd is not in use, look for the process with ps aux | grep -E 'nscd|dnsmasq').

  • systemd-resolved (systemd 239 and later): resolvectl flush-caches. The systemd manual describes it as flushing "all DNS resource record caches the service maintains locally." You can check it worked with resolvectl statistics, which reports the current cache size.
  • systemd-resolved on older systemd (before the 239 rename): sudo systemd-resolve --flush-caches. Some current distributions still keep this as a compatibility alias even after adding resolvectl, so it is worth trying if resolvectl is missing but systemd-resolve is not.
  • nscd: sudo systemctl restart nscd restarts the whole service and clears its cache with it. To invalidate only the hosts cache without a restart, sudo nscd -i hosts works on distributions that ship that flag.
  • dnsmasq: sending it a HUP signal clears the cache without dropping the service, per its own man page: sudo killall -HUP dnsmasq. A plain sudo systemctl restart dnsmasq also works and additionally reloads its configuration.

How to clear the browser's own DNS cache

Chrome keeps a DNS cache of its own, separate from the operating system's, so flushing the OS cache alone often is not enough to see a change take effect. Open chrome://net-internals/#dns and click Clear host cache. Chromium-based browsers (Edge, Brave, Opera and others) expose the same page at the same address.

That still may not be the whole fix. Chrome also keeps a pool of already-open connections to the old IP address and can reuse one of them instead of making a new connection, even after the DNS cache is empty. Open chrome://net-internals/#sockets and use Flush socket pools to close those out as well. If a site still loads the old version after both steps, try a private window, since it starts with no cached connections at all.

Why the old address still appears after flushing

If you have flushed every cache on the machine and the browser still shows the old server, the delay usually is not local anymore. A home router typically runs its own small DNS cache for every device on the network, and rebooting it clears that layer. Beyond the router, your ISP's resolver keeps its own cache too, and you have no direct way to flush that one; it clears itself once its cached entry's TTL runs out.

TTL, the time-to-live value on a DNS record, is the real limit on how fast a change can spread. Every resolver between you and the authoritative nameserver is allowed to hold an answer for exactly that many seconds before it is required to ask again. A record with a one-hour TTL can legitimately still return the old address to some visitors nearly an hour after it changed, no matter what you flush on your own machine. See how DNS propagation works for what controls that timeline and how to check whether a record has finished updating everywhere.

Frequently asked questions

Do I need to restart my computer after flushing DNS?

No. Every command above takes effect immediately and only clears the in-memory cache; a restart is not part of the process on Windows, macOS or Linux.

Why did flushing DNS not fix the problem?

Three things are commonly still holding the old answer: the browser's own cache (clear it separately at chrome://net-internals/#dns), the router serving your network, or the record's TTL simply not having expired yet anywhere else on the internet. If a lookup still fails or times out entirely rather than returning a stale answer, that points to a DNS server that is not responding rather than a caching issue.

How do I flush DNS on my phone?

Neither iOS nor Android exposes a manual DNS flush command. Turning airplane mode on and back off, or switching from Wi-Fi to cellular data and back, forces the device to drop its cached DNS state and re-resolve on the next request.

Does flushing DNS fix slow page loads?

Rarely on its own. A corrupted or oversized local cache can add a small delay, but consistently slow lookups are more often caused by the resolver itself. See why DNS lookups are slow for the more likely causes and how to test them.

What is the difference between flushing DNS and clearing browser cache?

Browser cache stores page content: HTML, CSS, images and scripts. DNS cache stores only the hostname-to-IP mapping used to find the server in the first place. Clearing one does not clear the other, and a stale page can be caused by either.

How do I confirm the flush worked?

On Windows, run ipconfig /displaydns right after the flush; it should come back nearly empty. On Linux with systemd-resolved, resolvectl statistics reports the current cache size. macOS has no equivalent inspection command, so the practical check is to look up the domain again with dig example.com or run a check from outside your own network with a tool like a DNS lookup that queries from multiple locations at once, which also rules out whether the stale answer is local to you or coming from the domain's own nameservers.

Check it now

Run the free check against your own site - no account needed.

Dns query

Monitor this permanently

Get alerted the moment it breaks: HostTracker checks from 300+ locations and notifies you by email, SMS, Slack, Telegram and more.

HostTracker features

More in this section: Fix it: guides for the errors people actually hit