How To Clear DNS Cache In Mac OSX 10.9 Mavericks

How To Clear DNS Cache In Mac OSX 10.9 Mavericks


DNS request are usually cached, that’s good as it help to speeds up the lookups within the same host but sometimes we will want to clear the cache so it don’t hold the values that are no longer valid or we edited hosts file to block or redirect hosts or IP. To clear DNS cache in Mac OSX, we can do it with the help of Terminal.

Mac-OS-X-10.9-Mavericks-System-Compatibility-List

Mac OSX 10.9

Open up the application called “Terminal”

Type this command:

dscacheutil -flushcache

To reload DNS type this command:

sudo killall -HUP mDNSResponder

 

 

For older versions of OS X go here.

 

For new OS X 10.10 Yosemite go here.

 

If you need to edit hosts file go here.

9 Comments

  1. Vicenzo Moderata
    Dec 01, 2013 @ 17:50:12

    Hello,

    When I do the command, for example,

    dig http://www.google-analytics.com

    I get the response:

    http://www.google-analytics.com. 71217 IN CNAME www-google-analytics.l.google.com.
    www-google-analytics.l.google.com. 156 IN A 201.17.31.88

    The number 156 means that this entry still has 156 seconds of live in the cache.

    When I do the command mencioned in your article, to flush the cache, and do the dig again, the number does not start to count again….

    If the cache was flushed, it wasn’t suppose to start to count from 300 again???

    Kind regards,
    Vicenzo

    Reply

  2. iHash
    Dec 01, 2013 @ 22:47:25

    No You are wrong. This TTL is from DNS server and not from your mac. Every DNS server is having set their own TTL usually 300 seconds.

    Try this command to get your DNS cache list “sudo dscacheutil -cachedump”, but it was reported by many users that this command is not always working on Mavericks.

    Reply

  3. Katie Overbeek
    Jan 05, 2014 @ 00:34:43

    After I follow these instructions it prompts me to enter my password, but will not let me type it out. Unsure what to do?

    Reply

    • iHash
      Jan 05, 2014 @ 09:34:01

      Just type password and press enter.

      Reply

  4. Bryant
    Feb 07, 2014 @ 02:22:02

    Is there any other way to flush dns? When Terminal asks for my password it doesn’t accept my keychain admin password.

    Reply

  5. Milan
    Feb 07, 2014 @ 09:23:18

    Are you typing correct password? You need admin password of your mac. For sudo commands you need admin rights.

    You can try with Onyx app it`s having option to clear DNS cache (Cleaning > Internet > Delete: DNS Cache).

    Reply

  6. Bryant
    Feb 08, 2014 @ 01:58:45

    I used my admin password with no result: old page came up after repeated tries. And just now got this on attempting to open page: HTTP Status 500: org.apache.tiles.impl.CannotRenderException: JSPException including path ‘head.jsp’.with a screen full of code. I also tried the Onyx leaning option. I tested the site on another computer and it works fine.
    Thanks for your response!

    Reply

  7. Bryant
    Feb 08, 2014 @ 02:00:12

    umm.. Onyx CLEANING option.

    Reply

    • Bryant
      Feb 08, 2014 @ 02:26:56

      I used Onyx again, and this time in the cleaning, I added the “bash” file to the list of checked items. It worked. Don’t have any idea what the bash file is, but the word appeared at the top of the terminal window, so I gave it a shot.

      Reply

Leave a Reply