MainspringGuides › Flush DNS Cache
macOS Guide

How to Flush the DNS Cache on Mac

Updated July 2026 · 3 min read

Your Mac remembers the answer to every DNS lookup for a while, so repeat visits to a site skip the round trip. That cache becomes a problem when a stored answer is no longer true — a site moved servers, you edited your hosts file, a VPN left junk behind. One Terminal line clears it.

The one-liner

Open Terminal (Applications → Utilities → Terminal) and run:

# flush the DNS cache — enter your password when asked
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

No output means it worked. There's nothing to undo here: flushing deletes nothing permanent, and the cache simply refills itself as you browse. No restart is needed either — the very next lookup goes out fresh. The same command works on macOS 13 Ventura, 14 Sonoma, and 15 Sequoia.

The semicolon just runs the two commands back to back; you can run them on separate lines if you prefer. Because both halves use sudo, you'll need an administrator account, and the password prompt shows nothing as you type — that's normal.

What each half does

You need both because lookups are cached at more than one layer. Running only one half is the usual reason a "flush" doesn't seem to take.

When flushing actually helps

Worth knowing before you reach for the command at all: cached entries expire on their own. Every DNS record carries a TTL — a lifetime set by the domain's owner, anywhere from thirty seconds to a day — and once it lapses, your Mac fetches a fresh answer without any help. Flushing is for when you can't afford to wait, or when a bad entry seems to be outliving its welcome.

Two things flushing won't fix: browsers keep their own DNS cache (quit and reopen the browser, or test in a private window), and your router may cache lookups for the whole network (reboot it if every device is affected).

Verify it worked

Ask the system resolver — the thing you just flushed — what it thinks a domain points to:

# what your Mac's resolver returns for a domain
dscacheutil -q host -a name example.com

# ask your DNS server directly, bypassing the local cache
dig example.com +short

If both return the address you expect (compare against the dig answer, which never comes from the local cache), the stale entry is gone. If dig itself returns the old address, the problem is upstream — your DNS server hasn't picked up the change yet, and no amount of local flushing will hurry it.

One more cross-check that mirrors what real apps do: ping -c 1 example.com resolves the name through the system resolver — the same path Safari and Mail take — and prints the address it picked on the first line. If ping shows the new address, your apps will see it too.

Skip the Terminal next time

While you're tuning your Mac, Mainspring turns 90+ hidden macOS settings into labelled, reversible toggles — every tweak has an off switch, no commands to memorize.

Try Mainspring free →

Signed & notarized by Apple · 1-day free trial · $29 once

Still not resolving?

If a flush doesn't help and dig shows correct answers, the fault is usually the DNS server your Mac is using. Switching to a fast public resolver like 1.1.1.1 or 8.8.8.8 takes a minute — see how to change DNS servers on your Mac.