LightAtom

How to Flush the DNS Cache on Mac (Every macOS Version)

One command clears the DNS cache on every macOS version since El Capitan. Here it is, plus browser caches and when flushing actually helps.

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Clear the macOS DNS cache. Works on macOS 10.11 El Capitan through macOS 15 Sequoia.

beginner2 minNeeds: Terminal, An administrator password

When to use it

Flush the DNS cache when a website moved to a new server but your Mac still goes to the old one, after editing /etc/hosts, after changing DNS servers, or when one site fails with a DNS error while others work.

What is the DNS cache? macOS remembers recent name lookups (apple.com → 17.253.144.10) for as long as each record's TTL allows, so it doesn't have to ask DNS again. Usually that's good; after a change it can hand out stale answers.

Steps

  1. Open Terminal

    Applications › Utilities › Terminal, or search for it with Spotlight (⌘Space).
  2. Run the flush command

    Paste the command and press Return. Type your administrator password when asked; it won't be shown as you type.
    sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  3. Clear the browser's own cache

    Chrome keeps a separate DNS cache. Open chrome://net-internals/#dns and click Clear host cache, then chrome://net-internals/#sockets › Flush socket pools. Safari and Firefox use the system cache (Firefox may also need a restart).
  4. Check the result

    Look the name up again. dscacheutil uses the same resolver path as apps.
    dscacheutil -q host -a name apple.com

Output explained

The flush command prints nothing when it works; that's expected. If you typed the password wrong, sudo asks again.

dscacheutil -q host -a name apple.com prints what macOS resolves now:

name: apple.com
ipv6_address: 2620:149:af0::10

name: apple.com
ip_address: 17.253.144.10

To see what's in the cache, run sudo killall -INFO mDNSResponder; mDNSResponder then writes its cache state to the system log, which you can read in the Console app by searching for mDNSResponder.

Options and variations

FlagMeaningExample
dscacheutil -flushcacheFlush the Directory Service cachesudo dscacheutil -flushcache
killall -HUP mDNSResponderTell mDNSResponder to drop its DNS cachesudo killall -HUP mDNSResponder
dscacheutil -q hostResolve a name the way apps dodscacheutil -q host -a name example.com

Common errors

ErrorCauseFix
Sorry, try again.Wrong password for sudoUse your Mac login password; the account must be an administrator.
Site still goes to the old serverThe browser's own cache, the router's cache or the old TTL at your ISPClear Chrome's host cache, restart the router, or wait for the TTL.
No matching processes were foundTypo in mDNSResponder (it's case-sensitive)Copy the command exactly.

Do it in the app

After flushing, LightAtom's connections view shows connections with the addresses names now resolve to.

Frequently asked questions

How do I flush DNS on a Mac?

Open Terminal and run sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder, then enter your password. It works on every macOS version since 10.11 El Capitan, including macOS 15 Sequoia.

Is it safe to flush the DNS cache?

Yes. It only deletes remembered lookups, which macOS rebuilds automatically. The first visit to each site afterwards takes a few milliseconds longer.

Does restarting a Mac clear the DNS cache?

Yes, a restart clears it. The flush command just does it without restarting.

How do I flush DNS in Chrome?

Open chrome://net-internals/#dns and click Clear host cache. Then flush socket pools at chrome://net-internals/#sockets so existing connections close.

Why didn't flushing DNS fix my problem?

The stale answer may come from your router or ISP resolver, which keep their own caches. Restart the router or switch to a public DNS server, and wait for the old record's TTL.

LightAtom team

The people who build LightAtom, a network monitor for macOS.