DNS cache is a local storage of DNS lookup results. Here's how it works: a device remembers which IP address corresponds to a particular domain. That way, when you visit the same site again, there's no need to query the DNS server from scratch every time.

So why would you ever need to flush the DNS cache? In practice, a common scenario looks like this: a site has moved to a new server, but the device is still trying to reach it at the old IP address. As a result, the site becomes unavailable and won't load. Flushing the DNS cache usually fixes the issue.

What is DNS cache and why does it matter

When a user types a domain name into the browser's address bar, the computer needs to figure out which IP address that domain points to.

The process looks like this:

Domain → DNS resolver → IP address → connection to the site

The response is temporarily stored in the DNS cache. The next time the user visits the same site, the system first checks the local record and, if it's still valid, uses it instead of sending a new query to the DNS server.

How long is a record kept? That's determined by the TTL (Time to Live) parameter, set by the DNS server for a specific record. Once the TTL expires, the result is considered stale and has to be fetched again.

It's worth not confusing several different levels of caching:

  • OS-level DNS cache — stored and managed by the operating system;

  • Browser DNS cache (host cache) — a separate mechanism built into the browser;

  • Browser HTTP cache — stores page assets such as images, CSS, JavaScript, and other resources.

Flushing the Windows DNS cache, for example, won't clear the cache in Chrome or Firefox.

When you need to flush the DNS cache

In some situations, flushing the DNS cache isn't just recommended — it's necessary.

Here are the common cases:

  1. The site has moved to a different server. This is one of the most frequent scenarios: the domain used to point to an old VPS, and after migration the DNS record was updated to a new IP.

  2. The site doesn't load for all users. This often happens due to a local DNS resolution issue.

  3. After DNS records were updated, the computer keeps using the old address.

  4. A connection error appears after the domain's DNS settings were changed.

  5. The site loads incorrectly only on one device or in one browser.

When you move a website from one server to another, users may still see different DNS responses for a while — and that, by itself, doesn't necessarily indicate a technical problem. It comes down to TTL and caching at various levels, which may still be serving the old DNS record; it just takes some time to fully propagate. It's important to keep in mind that clearing the local DNS cache only affects that specific device — it doesn't force DNS servers across the internet to instantly forget the old record.

How to flush the DNS cache on Windows

Flushing the DNS cache on Windows takes just a few simple steps. Windows 10 and Windows 11 use the same command:

ipconfig /flushdns

Microsoft documents this command as a way to flush and reset the DNS client resolver cache.

How to run it:

  1. Open the Start menu.

  2. Type cmd.

  3. Run Command Prompt as administrator.

  4. Run: ipconfig /flushdns

  5. Press Enter.

If it runs successfully, Windows will confirm that the DNS resolver cache was flushed.

You can view the contents of the DNS cache before clearing it with:

ipconfig /displaydns

After the flush, Windows will fetch fresh DNS responses as needed.

How to flush the DNS cache on macOS

On modern versions, flushing the local DNS cache on macOS is typically done with dscacheutil, followed by restarting DNS handling via mDNSResponder:

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

The first command clears the directory cache, and the second sends a signal to the mDNSResponder service, which handles DNS resolution and network service discovery on macOS. After running these commands, Terminal may not display a success message — that's normal.

How to do it:

  1. Open Terminal.

  2. Run: sudo dscacheutil -flushcache

  3. Enter your macOS user password if prompted.

  4. Then run: sudo killall -HUP mDNSResponder

For current macOS versions, the combination of dscacheutil and mDNSResponder remains the practical way to reset the cache.

How to flush the DNS cache on Linux

Flushing the cache on Linux is a bit different: there's no single universal command that works across all distributions. The method you need depends primarily on which DNS resolver is running on that particular system.

If the system uses systemd-resolved, run:

sudo resolvectl flush-caches

This flushes the DNS cache maintained by systemd-resolved. What's the advantage of this command? One important thing — it's supported by modern versions of systemd.

You can check the resolver's status with:

resolvectl status

If the resolvectl command isn't available, the system is using a different DNS resolution mechanism. On systems running Name Service Cache Daemon (nscd), you can flush the hosts cache with:

sudo nscd -i hosts

Another option is to restart the service:

sudo systemctl restart nscd

The exact method depends on your distribution's configuration and which services are installed.

dnsmasq

If DNS caching is handled by dnsmasq, it can be flushed by sending it a SIGHUP signal:

sudo systemctl restart dnsmasq

Upon receiving SIGHUP, dnsmasq clears its cache and re-reads the necessary data. So before flushing DNS on Linux, first figure out which resolver is actually running on the machine. Don't use the systemd-resolved command if the DNS cache is actually being handled by nscd or dnsmasq.

How to flush the DNS cache in Chrome

Chrome's DNS cache is a separate layer, so the Windows ipconfig /flushdns command won't clear it. In Chrome, you can open a dedicated page to flush the host cache:

chrome://net-internals/#dns

Then click Clear host cache. Chrome Community documentation refers to this as the way to clear the host cache. If the issue persists afterward, troubleshooting a connection problem may also require flushing the socket pool:

chrome://net-internals/#sockets

Use the Flush socket pools button. Important: clearing Chrome's host cache doesn't remove the DNS record at the registrar or DNS provider, and it doesn't change the DNS server your computer uses.

How to flush the DNS cache in Firefox

In Firefox, the DNS cache is also separate from the system cache. To view and clear it, open:

about:networking#dns

This page shows information about Firefox's DNS resolution and includes a Clear DNS Cache button. This is the standard way to flush Firefox's internal DNS cache.

If the issue isn't limited to DNS, you can also clear the browser's regular cache:

Menu → Settings → Privacy & Security → Cookies and Site Data → Clear Data.

Mozilla notes separately that Firefox's regular cache stores temporary site files — images, scripts, and other page elements. That's a different type of cache and shouldn't be confused with the DNS cache.

How to verify that the DNS cache has been flushed

After flushing, you can re-run a DNS query against the domain in question.

On Windows:

nslookup example.com

On Linux and macOS:

nslookup example.com

or:

dig example.com

The result will show the IP address currently returned for the domain. If the site was recently migrated to a new server, compare the returned IP with the new server's address. If DNS returns the expected IP but the site still doesn't load, the problem most likely isn't in the local DNS cache anymore.

Conclusion

DNS cache is a mechanism that speeds up working with domains and reduces the number of repeated DNS queries. The cache itself isn't a malfunction. If a site has recently moved to a new server, its IP address has changed, or a domain is behaving incorrectly only on one device, flushing the DNS cache is one of the simplest diagnostic steps you can take.

But it's not a universal fix. If, after flushing, the computer still gets the wrong IP or the domain doesn't resolve at all, you need to check the DNS records, the resolver being used, the DNS server, and the network connection. If flushing the DNS cache didn't help, move on to deeper troubleshooting of a DNS server not responding or a slow DNS lookup issue — the root cause may no longer be at the local cache level.