How to flush DNS cache on Mac using Terminal

5 min read

Want to clear DNS cache on Mac? If a site you visit regularly suddenly starts throwing out server not found error messages, or a DNS change you literally made two minutes ago still isn't showing up, something's not quite right.

Our Macs keep a hold of masses of local DNS cache data, and that's normal, but if anything becomes stale or gets corrupted, that’s when you’ll start bumping into issues like blocked sites, annoying wrong routing, or sudden strange offline troubles, regardless of a solid internet connection.

Contrary to what a lot of people think, flushing DNS is definitely not complicated; it’s a simple two-line Terminal command that takes around 10 seconds.

What DNS cache is (and why you should think about how to flush DNS on Mac)

Your Mac remembers the IP address of every site you visit so it doesn't have to look it up again; this ultimately means you get a much faster load time and experience, but it can go stale.

There isn’t one fixed reason why this happens; it can be down to a number of different things, from sites changing their IP, ISP, and pushing new domain updates, to DNS misconfigurations and issues with VPN toggling.

One thing for sure is when it happens, you’ll start seeing the “server not found" error, even old versions of a site loading up, or complete failure to access websites you previously had access to.

Flushing your DNS on a Mac is harmless and totally non-destructive; nothing but a temporary lookup list is deleted, so no important files or access to anything.

How to flush DNS cache on Mac (Terminal method)

I love this method, and that's why it’s top of my list.

  1. Open up the Terminal tool from your Applications > Utilities.

  2. Run:

  • sudo killall -HUP mDNSResponder and enter your password (you won’t be able to see it, but that's normal).

Terminal sudo command flushing DNS resolver via mDNSResponder restart

If nothing happens afterward, that’s actually a good sign. No output usually means the DNS cache was flushed successfully.

If you can’t deal with the not knowing, you can force a confirmation with:

  • sudo killall -HUP mDNSResponder; sudo dscacheutil -flushcache; say cache flushed

Terminal command flushing DNS cache and restarting mDNSResponder service

If you’re doubting if this is working, jump to the next section, because there are some macOS version-specific commands.

Flush DNS on Mac: version-specific commands

Go to Apple menu > About This Mac to see which version you’re using, then make sure you’re using the right command below.

macOS version

DNS flush command

macOS Sequoia, Sonoma, Ventura, Tahoe

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

macOS Monterey, Big Sur, Catalina, Mojave, High Sierra

sudo killall -HUP mDNSResponder

OS X El Capitan to Sierra

sudo killall -HUP mDNSResponder

OS X Yosemite

sudo discoveryutil udnsflushcaches

Other ways to clear DNS cache on Mac without Terminal

I do appreciate Terminal, but just isn’t for everyone, and if that’s you, don’t worry there’s a couple of other methods to reset the DNS cache on a Mac without running any command lines.

1. Toggle off and on your Wi-Fi

This is kind of a soft cache refresh, but it does resolve minor connection issues and is definitely worth a shot.

System Preferences - macOS Wi-Fi settings showing active network connection and list of available nearby networks  

2. Change DNS servers

Go to your System Settings > Network > Wi-Fi > Details > DNS, then add a DNS provider like 1.1.1.1 or 8.8.8.8. This will force your Mac to refresh how it looks up websites.

macOS Wi-Fi DNS settings showing custom DNS server address

3. Restart your Mac

Everyone forgets this one, but every time you restart your Mac, you’re flushing everything, including the DNS cache, so if it’s been a while, this will probably solve it.

Apple menu showing Restart option to reboot Mac

4. Use a third-party tool

I reach for the Performance module from CleanMyMac quite a lot, and it does come with a Flush DNS Cache option in its maintenance tasks. So, if you’re still having issues and the above tips didn’t work, this is worth a try. And if you haven’t already, you can properly test it for 7 days — get your free trial here.

Flush DNS cache in Maintenance  

You’ll also see other features like Spotlight reindexing and repairing disk permissions, which are all worth running if the DNS issue you’re trying to fix turns out to be part of a bigger system issue.

If you are a Terminal lover, MacPaw, the makers of CleanMyMac, have also just launched CleanMyMac CLI (public beta); you can install it via Homebrew with:

  • brew install --cask cleanmymac-cli

Then use:

  • cleanmymac optimize

CleanMyMac optimize freeing up RAM and purgeable disk space

DNS flush didn't fix it; what to try next

If flushing DNS cache on your Mac didn’t solve the problems you’ve been having, then it’s possible that the stale record might not be on your Mac.

1. Check your browser first

Browsers like Chrome (or even Firefox and Safari), all keep their own DNS or site data. Start by quitting and reopening them and trying again.

In Chrome, you can also go to:

  • chrome://net-internals/#dns

Chrome browser DNS lookup page for clearing host resolver cache

Then click Clear host cache.

2. Restart your router

It’s an annoying step, but this will force a fresh connection. So give it a quick restart, wait for it to load back up, and test again.

3. Switch DNS providers

If you didn’t try this already in the alternative methods, then it’s really worth a try now. Go back to your System Settings > Network > Wi-Fi > Details > DNS. Add 1.1.1.1 or 8.8.8.8, then test the site again.

4. Disconnect your VPN

VPNs are known to reroute DNS requests, and this just makes troubleshooting confusing, so I’d try disabling it temporarily to see if that solves your issue.

macOS VPN settings on Mac

5. Check what your Mac is actually resolving

In Terminal, run:

  • nslookup example.com

But replace example.com with the domain that isn’t updating. If you find your DNS issues keep coming back, then I’d really recommend trying that Performance module from CleanMyMac, because it can find and solve issues with background apps, network-heavy processes, and leftover VPN-related clutter in one scan.

So, that's all the methods for clearing DNS cache on Mac, hopefully you found something here that works.