How to Flush DNS Cache in Mac OS X

Mar 21, 2008 - 20 Comments

Flush DNS Cache in Mac OS X Whether you’re a systems administrator or a web developer, or anything in between, chances are you’ll have to flush your DNS cache every once in a while to get things straightened out server-side, or even just for testing certain configurations.

Flushing your DNS cache in Mac OS X is actually really easy, but there are actually several different commands to use, and you will find the commands are unique to different versions of Mac OS X. We’ve got you covered regardless of what version of Mac OS X you’re running, from MacOS Sierra 10.12, 10.11, 10.13, OS X 10.10, OS X 10.9, all the way back to 10.4. So find your version of OS X, open your Terminal, and follow the appropriate directions below to get started.

Remember, each of these commands must be entered into the command line, by way of the Terminal applications (found in /Applications/Utilities/ in all version of Mac OS X). Launch that app first and then you can just copy and paste the commands in if you’d like.

Flush DNS Cache in MacOS Monterey 12, macOS Big Sur 11

With macOS Monterey, Big Sur, and newer, you can use the following command line string to flush DNS cache:

sudo killall -HUP mDNSResponder

Flushing DNS Cache in MacOS 10.12, 10.11 newer

For Sierra, El Capitan, and newer Mac OS releases:

sudo killall -HUP mDNSResponder

Clearing DNS Cache in OS X 10.10 Yosemite

Running Yosemite? Clearing DNS caches in OS X Yosemite has changed again, split into MDNS and UDNS or combined like we’ll use below, here’s the command that is needed:

sudo discoveryutil mdnsflushcache;sudo discoveryutil udnsflushcaches;say flushed

You can read much more about resetting and flushing DNS cache in OS X Yosemite here if you’re interested.

Flush DNS in OS X 10.9 Mavericks

Rere is how to flush the DNS cache in 10.9:

dscacheutil -flushcache;sudo killall -HUP mDNSResponder

You will need to enter the admin password for this task to complete. If you notice, it combines killing mDNSResponder with the standard dscacheutil, making it a two step process to first, flush cache, then reload the DNS handling in OS X so that the changes take effect.

Flushing DNS Cache in OS X Lion (10.7) and OS X Mountain Lion (10.8)

Launch Terminal and enter the following command, you will need to enter an administrative password:
sudo killall -HUP mDNSResponder
Note the dscacheutil still exists in 10.7 and 10.8, but the official method to clear out DNS caches is through killing mDNSResponder. You can also find that process running in Activity Monitor.

One helpful trick if you find yourself flushing the DNS frequently is to setup an alias for that command string in your .bash_profile or in the profile of your shell of choice. A simple bash alias for flushing cache could be this:

alias flushdns='dscacheutil -flushcache;sudo killall -HUP mDNSResponder'

Save that into .bash_profile, then typing “flushdns” would prevent having to use the full command string in the future.

Flush DNS Cache in Mac OS X 10.5, Mac OS X 10.6

Launch Terminal and issue the following command:
dscacheutil -flushcache
All done, your DNS has been flushed. On a side note, the dscacheutil is interesting in general and worth taking a look at, try the -statistics flag instead for some stats.

Flush DNS in Mac OS X 10.4 Tiger, & 10.3

Type the following command in the Terminal:
lookupd -flushcache

That’s it, that’s all there is to it. Now your DNS settings should be as you intended them to be, which you can easily verify with various networking tools like http, ping, nslookup, traceroute, curl, or whatever else is appropriate to your specific situation.

If you find something isn’t working and DNS does not appear to have changed, verify the version of OS X you’re running and use the appropriate commands for the latest version. If you’re still having problems after that, try a different machine ideally on a different network (like a cell phone) to verify that it’s not an issue with the remote server.


Related articles:

Posted by: Paul Horowitz in Command Line, How to, Mac OS, Tips & Tricks


» Comments RSS Feed

  1. Lucia says:

    Using Mac OSX Sierra. Entered code to clean DNS “sudo killall -HUP mDNSResponder” into terminal. It shows “Password” with what looks like KEY. I tried entering the password after the KEY. Nothing happens. How do I know the terminal is cleaning the cache or not? I used my password to start the computer prior to attempting the cleaning. Using same password in terminal. Please respond. Computer running terribly slow.

    • Corey says:

      I have Mac high Sierra 10.13.6. I had the exact same issue as you. I was attempting to clear the cache because of problem with playing iTunes audio but like you I could not enter the password. In my case, however, a simple computer restart fixed the iTunes problem.

    • Keith says:

      the website is a joke above that I entered in.

      When you use sudo prior to a command it will prompt you for a admin password. if you are the only user on your computer then you might be the admin account. so we will assume as much. when it prompts you for the password it will show the key symbol and as you type it will show nothing. this is inherit to the unix and linux operating systems. that’s normal. if you type it in wrong it will say so. if you typed it in correctly it will just run the command. usually when you enter a command and nothing is returned to confirm whether or not it worked just a new line with your computers name, then that means the command was accepted. Your Mac is prob running slow for a host of reasons. scour the internet for walk throughs. don’t do anything more then these above simple commands if you are unable to have the off chance of corrupting your system and losing your data. the best thing you can do for yourself and you sanity is to go buy a external hard drive hdd that’s double the amount of space you have on your current Mac. copy over all your important files. then shut down completely your Mac. then start up your Mac by hitting the power button but as quickly as you can after hitting the power button hit and hold down command, option on the left side of the keyboard as well as the letters p and r. your Mac will flash on and chime then flash off. then on again a chime. and then off. let it do it one more time and let it load fully an log into your admin account and let it load up. then shut own fully. if you have a removable battery. remove it. and then hold down the power key until you see the power on light at the bottom right where the monitor meets the keyboard on the outer side flash and then turn offf. put battery back in and hit the power button. if you have a Mac that doesn’t have a removeable battery on the left side hit and hold down the option, control, and shift button for 10 sec then continue holding down hose keys and at the same time hold down the power on button for an additional 15 seconds. so total 25 seconds. then release the keys. turn on your Mac load it all the way and log in. then shut down again. hit the power key. and then immediately hit and hold the shift key all the way to the log in screen. type in your password. before hitting enter hold down the shift key once more and hit enter. you will be loaded into safe mode as admin. as admin go to safari. clear your history from all time. get rid of. all open tabs. go into settings and clear and website data. then go to your search engine which is similar or is like google.. type in onyx titanium. look for the office titanium site. download for your version of Mac OS, the correct version of onyx. once downloaded and installed it will prompt you to allow it to control your computer. follow the on screen directions.. if you’re confused go to security in the preference panel. go to I think privacy or some tab and go to disk access in the box and check the box next to onyx. also while you’re there make sure your firewall is on and stealth mode is on. block all connections if you don’t need anything communicating w the internet freely. once you do that re load onyx. go to the maintenance tab. click all the boxes and hit execute. let it do its thing. let it finish. if you have to leave it running all day then do so. once done it will restart. when its restarted. load all the way up normally. log in. then shutdown fully. now hit the power button and then hit immediately command and the letter r art the same time.. hold them down until you see a welcome prompt. go to disk utility. run first aid on all your drives and volumes. before that click the box that says view all drives. then run first aid on everything. do it twice. then shut down fully. turn Mac back on an load normally. I wish I new of a good virus/malware free program for you besides avg antivirus. I liked them 10 years ago but they’ve gone a different way.. anyways. just do the trial version. run a virus malware trojan scan on everything. Macs get malware all the time and we download trojans unaware all the time and so on.. I can’t say anything about viruses but malware and trojans yes. there’s much more you can do. you can run the recovery drive again at startup which was the command and letter r keys that brought you to do the first aid stufff. there’s adoption in there that allows you to reinstall the Mac OS youre running w out wiping your drives. do that if you can. you don’t necessary have to do all those things In that order. you can do them differently but you most likely have malware and other things messing your performance up. good luck.

  2. Trang Dao says:

    I followed how to Flush DNS in OS X 10.9 Mavericks
    Copy paste this:

    dscacheutil -flushcache;sudo killall -HUP mDNSResponder

    But it never asks me for the admin password ?!

    How to reload the DNS handling in OS X so that the changes take effect ? What and where is DNS ?

    What changes should I expect and how could I verify if any change took place at all ?

  3. Steve says:

    Is there any potential security benefit that could be gained from flushing the DNS Cache?

  4. don rhodes says:

    Cox techies suggest I “flush DNS” I have yosemite 10.10.2
    How do I do this

  5. johnny99 says:

    love the alias shortcut. how could I set this up in Automator to run at start-up? thanks!

  6. iFXBR says:

    Script for all OS version:

    export OS=`sw_vers | grep ‘ProductVersion:’ | grep -o ‘[0-9]*\.[0-9].’`
    echo DNS Flush Cache
    case $OS in
    10.9.|10.8.|10.7.) dscacheutil -flushcache; sudo killall -HUP mDNSResponder ;;
    10.6.|10.5.) dscacheutil -flushcache ;;
    10.4.|10.3.) lookupd -flushcache ;;
    echo Done!

  7. Kev McGowan says:

    Apple have removed the RSS reader from the current version of Mavericks/Safari, so now the RSS feeds from torrent websites no longer work; is there any way to re-enable the RSS reader within Safari?

  8. […] You can verify your hosts modifications immediately with ping, Safari, or any other network app. Changes take effect immediately though some adjustments may need to be accompanied by a DNS flush. […]

  9. okcomputer says:

    Works Great on Lion. Cleared an issue I had with multiple hostnames

  10. Al Varnell says:

    I’ve heard this does not work in Lion and that you must use the following, instead:

    sudo killall -HUP mDNSResponder

  11. […] a Mac you may need to follow this up with flushing DNS cache, so open the Terminal and type the […]

  12. Mike says:

    Once I enter the command into Terminal, does any confirmation script appear to confirm the cache has been cleared?

  13. logicalnot says:

    As of today, the command works perfectly. Thank you.

  14. carset says:

    Does this function still work? I’ve changed my nameservers on a site I own and it’s been hours and I’m still getting the old results… I’ve tried flushing the dns and it’s still not working.

    • htech says:

      Changing Name Servers requires a propagation time as network data centers need to re-cache your change. It usually takes about an hour, but can be up to about 24 hours depending on your location and service provider

    • aaron says:

      If you can log into a remote machine (ssh) you could check from there. So a VPS or even a dreamhost/hostgator account with SSH access. Or you could use your phone or another computer in your house.

  15. Cherooo says:

    thank you very much for this article, I wanted to ask you please how can erase our dns cache?

Leave a Reply


Shop on and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks


iPhone / iPad



Shop on Amazon to help support this site