Back to lessons

Apple Terminal

Flush macOS DNS Cache

macOS may keep using cached DNS answers after a domain, hosts entry, or local network record changes.

Command

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

What changed

The local DNS cache is flushed and mDNSResponder is signaled to reload.

Danger

caution

When to use it

Use after DNS changes, hosts file edits, local domain testing, or VPN resolver confusion.

When not to use it

Do not use it to fix authoritative DNS propagation. It only affects your Mac.

Undo or recovery

No undo needed. DNS answers will be cached again naturally as you browse.

Expected output

Usually no output, though sudo may ask for a password.

demo script

Disposable terminal steps

  1. printf '%s\n' 'Before: example.test -> 192.0.2.10'
  2. printf '%s\n' 'sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder' 'After: run a fresh lookup with dig example.test'

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ printf '%s\n' 'Before: example.test -> 192.0.2.10'
Before: example.test -> 192.0.2.10
::exit-code::0
$ printf '%s\n' 'sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder' 'After: run a fresh lookup with dig example.test'
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
After: run a fresh lookup with dig example.test
::exit-code::0

YouTube Short

Flush Mac DNS.

If DNS changed but your Mac keeps using the old answer, flush the local cache and signal mDNSResponder.

LinkedIn hook

Changed DNS but your Mac still visits the old place? Flush the resolver cache.

Question: When DNS debugging gets weird, do you check local cache before waiting on propagation?

experiments

A/B tests to run

Metric: comment_confusion_rate

A: Emphasize local-only cache behavior.

B: Emphasize the command and mention scope later.