ToggleHosts
Buy ToggleHosts
How to Flush DNS Cache on Windows, macOS & Linux (2026)

How to Flush DNS Cache on Windows, macOS & Linux (2026)

8 min read

Flush the DNS cache on Windows, macOS and Linux. Copy the command for your OS, verify it worked, then clear the browser cache if the old IP still loads.

Manage hosts files without the terminal

ToggleHosts helps you manage environments visually on Windows, macOS, and Linux, with automatic DNS flush and backups.

Copy the command for your OS and run it.

  • Windows 10 / 11 (CMD): ipconfig /flushdns
  • Windows 10 / 11 (PowerShell): Clear-DnsClientCache
  • macOS Ventura, Sonoma, Sequoia, Tahoe: sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder
  • Linux (systemd-resolved): sudo resolvectl flush-caches

Need a deeper walkthrough for one system? See flush DNS on Windows, flush DNS on Mac, or flush DNS on Linux.

What is DNS cache and why flush it?

Every time you visit a website, your operating system saves the result of that DNS lookup locally. That saved result is the DNS cache: a temporary record that maps domain names to IP addresses.

It exists for speed. Caching means your system does not hit a DNS server on every request.

The problem is that the cache goes stale.

If a domain's IP address changes because you updated your hosts file, switched dev environments, or a DNS record propagated, your machine keeps serving the old answer. You get the wrong site, a broken page, or a connection error. Nothing in the browser tells you why.

Flushing the DNS cache wipes those stale records. Your OS then performs fresh lookups and picks up the current IP addresses.

It is one of the most common first steps in DNS troubleshooting, and one of the most misunderstood. For the lookup order (hosts file, then cache, then resolver), see how DNS resolution works.

How to flush DNS cache on Windows 10 and 11

Windows 10 and Windows 11 use the same commands. You have two options: Command Prompt or PowerShell.

Option 1: Command Prompt

  1. Press Win + S, type cmd, right-click Command Prompt, and select Run as administrator.
  2. Run:
TEXT
ipconfig /flushdns
  1. You should see:
TEXT
Windows IP Configuration

Successfully flushed the DNS Resolver Cache.

That is it. The DNS resolver cache is cleared.

Option 2: PowerShell

Open PowerShell as administrator and run:

POWERSHELL
Clear-DnsClientCache

No output means success. This cmdlet is the PowerShell equivalent of ipconfig /flushdns. Both wipe the DNS client resolver cache.

Do you need admin rights? Yes. On Windows, flushing the DNS cache needs an elevated prompt. A standard user account typically returns an access error.

ipconfig /flushdns tells the Windows DNS Client service to discard cached records. Clear-DnsClientCache does the same via the DnsClient module. Use whichever terminal you already have open.

Verify with:

TEXT
ipconfig /displaydns
nslookup myproject.test

WSL2 keeps a separate resolver from Windows. Flush inside the distro with sudo resolvectl flush-caches, or run wsl --shutdown from Windows. Full WSL2 mapping: sync WSL2 with the Windows hosts file.

If the change still does not apply, see the full Windows flush DNS guide. After editing the file itself, use how to edit the hosts file on Windows 11.

How to flush DNS cache on macOS

The command is the same across macOS Ventura (13), Sonoma (14), Sequoia (15), and Tahoe (26). Apple has kept this sequence since macOS 10.10.4.

Open Terminal (Cmd + Space → type Terminal → Enter) and run:

BASH
sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder

Enter your admin password when prompted. No output is normal. Silence means it worked.

PartWhat it does
sudo dscacheutil -flushcacheClears the local DNS cache via Directory Services
sudo killall -HUP mDNSResponderSends a hang-up signal to mDNSResponder so it reloads and drops cached records

Both parts are needed. Running only one of them may leave residual cached entries. && runs them in order and stops if the first command fails.

Older macOS versions

  • macOS 10.10.4 and later (all current versions): sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder
  • macOS 10.10 – 10.10.3: sudo discoveryutil mdnsflushcache
  • macOS 10.6 – 10.9: sudo dscacheutil -flushcache

Verify with ping myproject.test or dscacheutil -q host -a name myproject.test. macOS prints nothing on a successful flush, so the ping is the real check.

If you are on Ventura, Sonoma, Sequoia, or Tahoe, use the two-part command above. Version-by-version commands: flush DNS on Mac. Dedicated Tahoe notes: macOS Tahoe flush DNS. To edit /etc/hosts: edit the hosts file on Mac.

How to flush DNS cache on Linux

Linux does not have a single universal flush command. It depends on which DNS resolver your system uses.

Ubuntu and Debian (systemd-resolved, default since Ubuntu 16.04)

BASH
sudo resolvectl flush-caches

Verify it worked:

BASH
sudo resolvectl statistics

Look for Current Cache Size: 0 in the output.

Older syntax (still works on some systems):

BASH
sudo systemd-resolve --flush-caches

Fedora / RHEL / CentOS Stream

Fedora also uses systemd-resolved by default:

BASH
sudo resolvectl flush-caches

If your system uses dnsmasq instead:

BASH
sudo systemctl restart dnsmasq

Arch Linux

Arch with systemd-resolved:

BASH
sudo resolvectl flush-caches

Arch with nscd:

BASH
sudo nscd -i hosts

Quick reference

Distro / serviceCommand
Ubuntu / Debian (systemd-resolved)sudo resolvectl flush-caches
Fedora / RHEL (systemd-resolved)sudo resolvectl flush-caches
Arch (systemd-resolved)sudo resolvectl flush-caches
Any distro with dnsmasqsudo systemctl restart dnsmasq
Any distro with nscdsudo nscd -i hosts
Any distro with BINDsudo rndc flush

Not sure which resolver you are running? Check with:

BASH
systemctl is-active systemd-resolved

If it returns active, use resolvectl flush-caches. Plain glibc has no DNS cache, so a flush is only needed when a caching service is running. Resolver-by-resolver steps: flush DNS on Linux. To edit the file: edit the hosts file on Ubuntu.

Common reasons to flush DNS cache

You should not flush DNS every day. These situations call for it immediately.

1. You edited your hosts file

This is the big one for developers. You added a local override, pointing myapp.local (prefer .test) to 127.0.0.1, but the browser still loads the old IP. Your OS cached the previous lookup before the edit. Flush the cache and the new entry takes effect.

2. You are switching between dev environments

Staging, production, local: each has a different IP. If you toggle between environments and hosts changes are not sticking, a stale DNS cache is almost certainly the culprit.

3. DNS propagation is not reflecting

You updated a DNS record at your registrar. The TTL expired. Your machine still resolves to the old IP. That is the local DNS cache holding the previous answer. Flush it and re-test.

4. You are troubleshooting connection errors

ERR_NAME_NOT_RESOLVED, DNS_PROBE_FINISHED_NXDOMAIN, or a site that will not load: a DNS flush is worth trying before you dig deeper. Dedicated error guide: DNS_PROBE_FINISHED_NXDOMAIN.

A note on browser DNS cache

Flushing your OS DNS cache is not the same as clearing your browser's DNS cache. Chrome, Firefox, and Edge each keep an internal DNS cache, separate from the OS.

If you flushed the OS cache and the problem persists, clear the browser cache too.

For Chrome, open:

TEXT
chrome://net-internals/#dns

Click Clear host cache. Then go to chrome://net-internals/#sockets and click Flush socket pools. Restart Chrome if the old connection is still held.

Firefox: about:networking#dns → Clear DNS Cache. Edge uses edge://net-internals/#dns, same pattern as Chrome.

Always reload in a new tab. An old tab can reuse an open socket.

If the command line resolves correctly and the browser does not, the browser is stale. If both are wrong, check the hosts line itself: IP<space>hostname, no http://, no port. Checklist: hosts file not working.

Still seeing the old IP?

Work through this in order:

  1. Flush system DNS with the command for your OS above.
  2. Clear the browser DNS cache and open a new tab.
  3. Confirm the hosts line is IP hostname with a space or tab, no scheme, no port.
  4. Disable any VPN that forces its own DNS resolver.
  5. Recheck on the command line with nslookup, ping, or getent hosts myproject.test.

If the CLI is correct and the browser is not, flush the browser again. If the CLI is still wrong, the hosts file or another resolver is overriding you, not the cache.

Stop flushing DNS manually

If you regularly switch between local, staging, and production, you have run ipconfig /flushdns or sudo killall -HUP mDNSResponder more times than you can count.

ToggleHosts is a visual hosts file manager for macOS, Windows, and Linux. Every time you switch environment profiles, it flushes the DNS cache automatically: no terminal, no command to remember, no ten-minute wait wondering why the change is not showing up.

You define host entries once, group them into profiles (local, staging, production, client-X), and switch in one click. The DNS flush happens in the background.

One-time purchase. Works on all three platforms.

If you are tired of the loop (edit hosts, open terminal, flush, reload browser, repeat), ToggleHosts removes every step except the switch.

_Last tested: August 2026 on Windows 11, macOS 26 Tahoe, and Ubuntu 24.04._

Sources and further reading

Also readFlush DNS on Windows 10 and 11
Also readFlush DNS on Mac: commands by macOS version
Also readFlush DNS on Linux
Share this article

Frequently Asked Questions

Only when you need to. There is no benefit to flushing on a schedule. Flush after a hosts file or DNS record change, when a site resolves to the wrong IP, or while troubleshooting a connection error. Your OS manages the cache on its own.

Rarely. DNS cache exists to speed up lookups, so flushing it can make the first request to each domain slightly slower while the cache rebuilds. Slow internet is almost always the ISP, the router, or congestion. A flush will not hurt, but do not expect it to help with speed.

Yes, on all platforms. On Windows, use an elevated Command Prompt or PowerShell. On macOS and Linux, use sudo. A standard user account gets a permission error. On a managed machine, ask your IT admin.

Yes. Chrome keeps an internal DNS cache separate from the OS. Flushing system DNS does not touch it. Open chrome://net-internals/#dns and click Clear host cache. Firefox and Edge keep their own caches too.

DNS cache stores domain-to-IP mappings so the OS does not query a DNS server on every request. Browser cache stores page assets (HTML, CSS, JavaScript, images). You can have a stale DNS cache with a fresh browser cache, or the reverse. When troubleshooting, clear both.

Windows: ipconfig /flushdns (or Clear-DnsClientCache in PowerShell). macOS: sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder. Linux with systemd-resolved: sudo resolvectl flush-caches. Chrome: chrome://net-internals/#dns then Clear host cache.

Related Articles