How to Flush the DNS Cache on Mac
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
dscacheutil -flushcacheclears the Directory Services cache, which includes cached host lookups.killall -HUP mDNSRespondersends a hangup signal tomDNSResponder, the system daemon that actually performs DNS resolution. HUP tells it to reset — dropping its cache — without quitting; the process keeps running the whole time.
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
- A site just moved. Its DNS records changed, other devices see the new server, but your Mac keeps connecting to the old one (or to nothing).
- You edited
/etc/hosts. A flush makes the system notice your new entries immediately instead of eventually. - VPN weirdness. Connecting or disconnecting from a VPN can strand lookups that were answered by the VPN's resolver. A flush clears the leftovers.
- You switched DNS servers and want old answers gone right away.
- A dev or staging site you just repointed keeps loading the old deployment.
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.
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.