How to Flush DNS Cache in Mac OS X

Mar 21, 2008 - 10 Comments

If you’re a systems administrator or a web developer, chances are you’ll have to flush your DNS cache every once in a while to get things straightened out serverside. Flushing your DNS cache in Mac OS X is actually really easy, and there are two different commands to use, one for Leopard and for Tiger. Depending on your version of OS X, open your Terminal and follow the appropriate directions below:

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.

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 your DNS Cache in Mac OS X 10.4 Tiger

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.

Related articles:

Posted by: Bill Ellis in Command Line, How to, Mac OS X, Tips & Tricks

10 Comments

» Comments RSS Feed

  1. Cherooo says:

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

  2. 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.

  3. logicalnot says:

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

  4. Mike says:

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

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

  6. Al Varnell says:

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

    sudo killall -HUP mDNSResponder

  7. okcomputer says:

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

  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. [...]

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

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

OSXDaily on Facebook

OSXDaily on Google+

Shop at Amazon

Ad

Shared on Facebook