Guide: How to Flush the DNS Cache on macOS

Important: I am not affiliated with any of the manufacturers, brands, services, or websites listed on this page and this is my personal experience.  If you find this helpful and want to say thanks, please buy me a coffee or take a look at my book on Amazon. It keeps this page ad-free. Thank you!

If you’re coming from Windows, you probably are probably more than familiar with the ipconfig /flushdns command to clear the DNS Resolver Cache. Flushing the DNS cache is useful if you switch between DNS servers and it’s really useful to be able to flush the DNS cache if you use macOS Location Profiles.

Here’s the equivalent flushDNS command for macOS.

You will need to run this as a macOS Terminal command:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

You will be prompted for your macOS admin password in Terminal after you execute the command.

Use Apple Automator to flushDNS the macOS DNS Cache

If you want to get more sophisticated, you can run flush DNS as an app using AppleScript and Automator. This means you can literally type flushDNS in Apple Finder and voilla! your macOS DNS cache will be cleared. Just follow these steps:

  1. Press ⌘ +Space to search for and open the Automator application on your Mac.
  2. Select File > New and select the “Application” icon (top row, second from left).
  3. Click Choose.
  4. In the search Variables box, type AppleScript.
  5. From the left column, double-click the Run AppleScript command.
  6. In the AppleScript module, highlight “(* Your script goes here *)” and paste over it the following text.
do shell script "sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder" with administrator privileges
  1. Select File – Saved and name the app “flushDNS”
  2. You’re done!

It’s important to note, that you will still be prompted for your admin password when you run the flushDNS app, but at least you don’t need to type a long command. It will always require a password, not a fingerprint – this is because (I think) it needs to pass the password back to the terminal command line.

Now anytime you want to flush the macOS DNS Cache, you can ⌘ +Space and type flushDNS.

If you want to Customize the flushDNS application icon:

  1. In Finder right-click on “flushDNS” and select Info.
  2. In the new window, select the icon in the top right
  3. Then copy and paste the icon that you want to use onto the above icon. If you need a flushDNS icon, here’s what I use.

flushDNS

Hope this helps!

If you’re after more posts I have written about the Mac and macOS, you can check out this link. I document various macOS bug fixes, hacks and. tweaks to make macOS better. I also list my favorite free macOS apps.

Important: I am not affiliated with any of the manufacturers, brands, services, or websites listed on this page and this is my personal experience.  If you find this helpful and want to say thanks, please buy me a coffee or take a look at my book on Amazon. It keeps this page ad-free. Thank you!

Scroll to Top