brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: sudo killall -HUP mDNSResponder flushes the macOS DNS cache

macOS
~/tips/tip-dns-macos-flush-mdnsresponder

sudo killall -HUP mDNSResponder

Clears the cached DNS answers on a Mac with one command.

macOS does not have a dedicated flush command for its DNS cache. The cache lives in mDNSResponder, and you ask that process to drop it.

This needs sudo:

sudo killall -HUP mDNSResponder

The SS64 page for dscacheutil lists exactly this for macOS 10.10.4 and above and says the mDNSResponder restarts automatically, so the signal makes it reload and drop its answers. For older versions it lists sudo dscacheutil -flushcache instead. The man page for that command warns that the flush should only be used in extreme cases. On a current Mac the killall line is the one to use.

I only reach for it after a DNS change that should have taken effect and has not. First check with dig that the new record is live on your resolver:

dig example.com +short

If dig shows the new address and the browser still goes to the old one, a cache on the Mac or in the app is the likely cause. If dig shows the old address too, the cache sits upstream, in the resolver or at your router, and flushing the Mac changes nothing.

The caveat: browsers keep their own DNS caches, so a flush on the Mac does not always change what the browser does. Restarting the browser is the quick test. SS64 also remarks that normally there is no need to flush DNS entries, so this is a fix for a stale answer and not a routine step.

Further reading: dscacheutil on ss64

More macOS tips System Settings > Accessibility > Hover Text > When using the pointer A Smart Folder in Notes collects notes by tag, checklist or date Type # in a Mac note to tag it, then filter by tag in the sidebar tmutil isexcluded ~/Projects/app/node_modules Crop an image in Preview by dragging a frame and clicking Crop All macOS tips (99) All topics

Link