How to Flush the DNS Cache on a Mac (One Terminal Command)

Flush the DNS cache on a Mac with one Terminal command that works on macOS 26 and back to El Capitan, plus Chrome's separate cache and when flushing helps.

KapilUpdated 4 min read
DissectMac moving a list of large files to the Trash
On this page

To flush the DNS cache on a Mac, open Terminal and run:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Type your password when asked (nothing appears as you type) and press Return. There's no confirmation message; the cache is cleared as soon as the prompt comes back. This command works on macOS 26 and every version back to macOS 10.11 El Capitan.

This guide covers what the command does, when flushing DNS fixes a problem and when it won't, Chrome's separate DNS cache, and the other network resets worth trying if the flush doesn't help.

What the DNS cache is

Every time your Mac connects to a website, it first looks up the site's IP address through DNS, then stores the answer for a while so the next visit skips the lookup. That store is the DNS cache. It's small, a few kilobytes, and it clears itself as entries expire.

The problem comes when an entry is wrong. A website moves to a new server, you change DNS providers, a VPN leaves stale entries behind, or a network you were on gave a bad answer. Until the cached entry expires, your Mac keeps going to the old address, and you get "server not found", a site that loads for everyone but you, or a site that shows its old version.

Flushing the cache throws away every stored answer so the next lookup starts fresh. It's harmless: the only cost is a few milliseconds on the next visit to each site.

How to flush DNS on a Mac, step by step

  1. Open Terminal: press Cmd + Space, type Terminal, press Return.
  2. Paste the command:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  1. Press Return, type your Mac password, press Return again.
  2. Quit and reopen your browser, then try the site again.

The first half clears the directory services cache; the second tells mDNSResponder, the process that handles DNS on a Mac, to reload. Older guides list different commands for each macOS version; on anything from El Capitan onward, this one line is all you need.

If you want a confirmation, add a message:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; echo "DNS cache flushed"

Chrome has its own DNS cache

Chrome and other Chromium browsers (Edge, Brave, Arc) keep a separate DNS cache inside the browser, and flushing the system cache doesn't touch it. To clear it:

  1. In the address bar, open chrome://net-internals/#dns (in Edge it's edge://net-internals/#dns).
  2. Click Clear host cache.
  3. Open chrome://net-internals/#sockets and click Flush socket pools to drop existing connections too.

Safari and Firefox use the system resolver, so the Terminal command covers them. Restarting the browser after the flush clears any connections still open to the old address.

If flushing DNS doesn't fix it

The flush only fixes problems caused by a stale cached answer. If the site still won't load:

Renew the DHCP lease. Open System Settings > Network, select your connection, click Details, then TCP/IP, and click Renew DHCP Lease. This refreshes the addresses your router handed out, including the DNS server it told your Mac to use.

Try a different DNS server. In the same Details window, open DNS, click + and add 1.1.1.1 (Cloudflare) or 8.8.8.8 (Google). If the site loads now, your router's or ISP's DNS was the problem.

Turn the VPN off and on. VPN clients rewrite your DNS settings and sometimes leave them half-changed when they disconnect. Reconnect, then disconnect cleanly.

Check the hosts file. If someone has edited /etc/hosts to block or redirect a site, DNS never gets asked. Run cat /etc/hosts in Terminal; the file normally has only a handful of localhost lines.

Restart the Mac. A restart clears the DNS cache, renews the lease and restarts mDNSResponder in one go, which is why it fixes so many "can't reach this site" problems.

Does flushing DNS make a Mac faster?

No. The DNS cache exists to make lookups faster, so flushing it makes the next visit to each site marginally slower, by milliseconds. It won't speed up a slow Mac or a slow connection. If the Mac itself is slow, the cause is elsewhere; why is my Mac so slow goes through the usual reasons in order.

Does flushing DNS free up space?

No. The DNS cache is a few kilobytes held in memory, not on disk. If you're clearing caches to free storage, the ones that matter are in ~/Library/Caches; see how to clear cache on Mac.

Is it safe to flush DNS on a Mac?

Yes. Flushing the DNS cache deletes nothing except stored address lookups, which your Mac rebuilds automatically as you browse. No files, settings, passwords or history are affected. It's a standard troubleshooting step and can be repeated as often as you like.

Why does the flush command ask for a password?

Because sudo runs the command with administrator rights, which restarting mDNSResponder requires. Terminal doesn't show anything while you type the password, not even dots. Type it and press Return. If you get "command not found", check that the line was pasted in full; it's one line with a semicolon in the middle.

Kapil

Builds DissectMac and writes these guides from what the app finds on real Macs. Last checked this one on Sep 23, 2026.

More guides