Flush the local DNS cache
Low risk
What do risk levels mean?
- Read-only
- Inspects state without changing anything.
- Low risk
- Reversible with a routine follow-up command.
- Medium risk
- Changes state; undo path documented.
- Destructive
- Deletes or overwrites; confirmation required.
Clears the operating system's DNS resolver cache so stale records are discarded and the next lookup fetches fresh answers, typically after a DNS change or when a site resolves to an outdated address.
networkdnscacheflush
Commands
Clear the directory services DNS cache
sudo dscacheutil -flushcacheSignal the resolver daemon to drop its in-memory cache
sudo killall -HUP mDNSResponderVerification
nslookup example.comThe name resolves normally, confirming the resolver is healthy after the flush.
Undo
Not undoable
The cache cannot be restored, and does not need to be — it repopulates automatically as names are resolved.
Pitfalls
- The Linux command requires systemd-resolved; distributions using dnsmasq or nscd need "sudo systemctl restart dnsmasq" or "sudo systemctl restart nscd" instead.
- Browsers keep their own DNS caches, so a stale result inside a browser may also need a browser restart or its internal DNS cache cleared.