To flush the DNS cache on Mac, run:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Enter your password when prompted. The cache is now cleared.

What This Does

Your Mac stores DNS lookups (domain name to IP address mappings) to speed up browsing. Flushing the cache clears these stored lookups, forcing your Mac to fetch fresh DNS information.

When to Flush DNS

You should flush DNS when:

  • A website won't load but works on other devices
  • You just changed DNS settings and want them to take effect immediately
  • A website moved to a new server but you're still seeing the old version
  • You're getting "server not found" errors for sites that should work
  • You're developing locally and changed hosts file entries

The Command for Different macOS Versions

The command varies slightly by macOS version:

macOS Ventura, Sonoma, Sequoia (13+)

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

macOS Big Sur, Monterey (11-12)

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

macOS Catalina, Mojave (10.14-10.15)

sudo killall -HUP mDNSResponder

macOS High Sierra (10.13)

sudo killall -HUP mDNSResponder

For most modern Macs, the full command at the top of this page works.

Breaking Down the Command

Part Meaning
sudo Run with administrator privileges
dscacheutil -flushcache Flush the directory service cache
; Then run the next command
killall -HUP mDNSResponder Reset the DNS resolver

You need sudo because DNS is a system-level service.

Verify It Worked

There's no confirmation message. If you see no output and no errors, it worked.

To verify DNS is resolving correctly:

nslookup google.com

You should see an IP address in the response.

Also Check Your Hosts File

If you edited /etc/hosts manually, DNS flushing won't override those entries. Check your hosts file:

cat /etc/hosts

If there are entries pointing domains to wrong IPs, that's your problem - not DNS cache.

Browser DNS Cache

Browsers maintain their own DNS cache separate from the system. After flushing system DNS, you may also need to clear browser cache:

Chrome: chrome://net-internals/#dns → "Clear host cache"

Safari: Develop menu → Empty Caches

Firefox: Clear browsing data or restart the browser

Common Issues

"Password: " appears but nothing happens when I type

That's normal. Password input is hidden for security. Type your password and press Enter.

"Operation not permitted"

Make sure you're using sudo at the beginning of the command.

Still seeing old DNS

Wait a few seconds - DNS propagation through your router can take time. Also try restarting your router.

The website still shows old content

That might be browser cache, not DNS. Clear your browser cache or try incognito mode.

Create an Alias

If you flush DNS often, create an alias:

echo 'alias flushdns="sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder"' >> ~/.zshrc
source ~/.zshrc

Now just type flushdns whenever you need to clear the cache.


Keep Learning

DNS flushing is one of many system-level things Terminal handles easily. The free course covers more ways to manage your Mac effectively.

Check it out at Mac Terminal for Humans.