On modern macOS, clearing the DNS cache takes two commands run together: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder. The first empties the directory-service cache; the second restarts mDNSResponder, the process that actually does DNS resolution on a Mac. Running only the first is the mistake most guides make - it leaves the resolver holding its own copies, so the flush appears not to work. You need both, and you need sudo, because you are poking at a system service.
Table of contents
- The command that works
- Why two commands instead of one
- It changed across macOS versions
- When flushing helps, and when it will not
- Doing it without the terminal
- How this fits the rest of the stack
- FAQ
The command that works
Open Terminal (Applications, Utilities, Terminal) and run:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Enter your password when prompted - sudo needs it, and Terminal shows nothing as you type, which is normal. The semicolon runs both commands in sequence.
dscacheutil -flushcacheflushes the Directory Service cache, which includes DNS entries.killall -HUP mDNSRespondersends a hangup signal tomDNSResponder, restarting it so it drops its own in-memory cache and starts fresh.
There is no visible output on success, which throws people - a silent return means it worked. If you see command not found or a syntax error, you mistyped; retype it rather than assuming your Mac is different.
Why two commands instead of one
This is the part the one-command guides get wrong. On macOS, DNS resolution is handled by mDNSResponder (and a helper, mDNSResponderHelper). That process keeps its own cache in memory.
dscacheutil -flushcache clears the Directory Services cache layer, but mDNSResponder can still be holding resolved answers of its own. So flushing dscacheutil alone can leave stale entries live in the resolver. Restarting mDNSResponder with killall -HUP forces it to let go of everything and rebuild.
Running both is what actually gives you a clean slate. This is why a flush you ran from an old one-line guide sometimes seems to do nothing - it cleared one layer and left the resolver’s copy in place. The two-command form clears both.
It changed across macOS versions
The exact command has drifted over the years, which is why the internet is full of variants that no longer apply. On very old releases it was a single dscacheutil -flushcache; on some it was discoveryutil; the mDNSResponder restart became necessary again in later versions.
For every reasonably modern macOS - Big Sur, Monterey, Ventura, Sonoma, and later - the two-command form above is correct:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
If you are following a guide that gives only one command or mentions discoveryutil, it is written for an OS you are probably not running. When in doubt, the two-part command is the safe, current choice - it works on everything current and does no harm if one half is redundant.
When flushing helps, and when it will not
Delete the DNS cache when:
- A site loads elsewhere but fails on your Mac, especially just after it moved servers.
- You edited a domain’s DNS records and want your Mac to see the change without waiting for the TTL.
- You suspect a bad cached entry - one domain redirecting somewhere odd.
It will not help when:
- Your whole connection is down - fix Wi-Fi or Ethernet first.
- Every site is slow - that is bandwidth or your resolver, not the cache.
- The site itself is down - a fresh lookup just re-finds the same broken server.
If flushing does not fix a single-site problem, the next thing to check is your resolver: point the Mac at a public one like 1.1.1.1 in System Settings, Network, Details, DNS, and test again.
Doing it without the terminal
If you would rather not use Terminal, there is a partial alternative: toggling your network connection clears some cached state. Turn Wi-Fi off and back on, or unplug and replug Ethernet. This is not as thorough as restarting mDNSResponder, but for a quick stale-entry problem it sometimes does the job.
The most reliable non-terminal reset is a reboot - restarting the Mac restarts mDNSResponder along with everything else, giving you a clean DNS cache as a side effect.
For anything deliberate, though, the terminal command is faster and cleaner than rebooting. It takes five seconds, needs no restart, and clears exactly the thing you meant to clear. Keep the two-part command in a note and you never have to look it up again.
How this fits the rest of the stack
Clearing a Mac’s DNS cache is the local half of a bigger story: DNS answers are cached with a TTL everywhere, including between you and any app you deploy. When you point a domain at a service and it does not resolve yet, the fix is usually the same idea - a stale cache somewhere, waiting to expire or be flushed. The RunxBuild hosting calculator lays out the service, database, storage, and bandwidth as separate line items, and the RunxBuild dashboard is where the team watches deploys, logs, and restarts as they happen.
Useful related references:
- Redis Get All Keys: The Right Command, the Wrong Command, and the One That Will Take Down Production
- AWS Register Domain: DNS Is the Easy Part Until the App Needs to Go Live
- Command Prompt Flush DNS: ipconfig, PowerShell, and DNS Client Service
- Services on RunxBuild
FAQ
How do I delete the DNS cache on a Mac?
Run sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder in Terminal and enter your password. The first command flushes the directory-service cache and the second restarts the resolver so it drops its own copies. There is no output on success.
Why do I need two commands to flush DNS on a Mac?
Because DNS resolution is handled by mDNSResponder, which keeps its own in-memory cache. dscacheutil -flushcache clears one layer, but mDNSResponder can still hold stale answers. Restarting it with killall -HUP mDNSResponder clears that layer too, so you need both.
Does the Mac DNS flush command differ by macOS version?
It has changed over the years, which is why old guides vary. For every modern release - Big Sur through Sonoma and later - the two-command form sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder is correct. Guides using a single command or discoveryutil are for older systems.
Why is there no output after running the flush command?
Success is silent. Both dscacheutil -flushcache and killall -HUP mDNSResponder print nothing when they work. If you see command not found or a syntax error, you mistyped it. A silent return to the prompt means the cache was flushed.
Can I flush the Mac DNS cache without Terminal?
Partially. Toggling Wi-Fi off and on, or replugging Ethernet, clears some cached state, and a full reboot restarts mDNSResponder and gives you a clean cache. The Terminal command is faster and more thorough, but a restart works if you would rather avoid it.