Inert Ramblings

Everything worth saying has already been said…

Inert Ramblings
May 11, 2004 by Sciri

Mac OS X – Clearing DNS Cache

Once you go to a Web site, or do any DNS lookup, the IP gets cached for quite a while. This becomes a royal pain if you’re a systems administrator who is in the middle of migrating domains from one server to another. Executing sudo killall lookupd lookupd -flushcache clears the cache, restarts the caching daemon, and fetches fresh DNS records. And there was much rejoicing…

Updated November 26, 2007: Thanks to Syd, the Leopard (Mac OS X 10.5) command has changed to dscacheutil -flushcache and lookupd has been deprecated.

Posted in Gnus. RSS 2.0 feed.
« Cheap dedicated servers!
A fistful of quickies… »

27 Responses to Mac OS X – Clearing DNS Cache

  1. rentzsch says:
    May 11, 2004 at 8:23 PM

    `lookupd -flushcache` works as well. No sudo required.

  2. Sean says:
    May 11, 2004 at 11:02 PM

    Hrm. I really should have thought of that. ;) Thanks!

  3. Andrew says:
    May 13, 2004 at 6:44 PM

    *shudder*

    killall scares me from my DEC Unix days. ps | grep | awk | xargs -n 1 kill, or skill if your platform supports it.

    /Andrew

  4. Lazer says:
    July 29, 2004 at 1:05 AM

    While “lookupd -flushcache” seems to work in most instances, I’ve discovered that it doesn’t fully flush the cache when dealing with a PPTP VPN link (and probably any PPP link for that matter). In this instance, and if a host is accessible both publically and across the private network via VPN, and if lookupd has already looked up the public address, making the VPN connection then issuing a flushcache does not successfully force lookupd to release record of the public address. As evidence of this, a ping to the target hostname continues to point to the public address until lookupd is killed (sighup). Note: this scenario assumes that during the VPN connection the default route is not pointing to the private network (hence all public traffic is routed across the public, not private link).

    In this instance a killall or the like seems to be the only solution. (c’mon it’s only a killall!)

  5. Pingback: ONE/Northwest KnowledgeBase

  6. Pingback: takecover!

  7. ramz says:
    February 1, 2005 at 11:47 PM

    quick question…after you enter this command, lookupd -flushcache does terminal give you a “Flushed” message or a “cleared” message or something, I used this but I’m not sure if it worked. How do I check?

  8. Sean says:
    February 2, 2005 at 10:48 AM

    Nope. No output is generated since the command is meant to be silently run from scripts. If you didn’t get an error then the command worked. Just to be safe, you may want to quit and relaunch any network applications (Mail, Safari, Firefox, etc.) since they sometimes keep their own caches.

  9. Pingback: The Room

  10. stan says:
    February 16, 2006 at 7:47 AM

    That’s strange, but on my computer lookupd -flushcache don’t work. Instead, I invoke interactive lookupd prompt: lookupd -d, then type the command ‘flushCache’
    strange…

  11. Dan says:
    June 20, 2006 at 3:52 PM

    Help! I am not as technical as most. I am the only Mac in our environment. I cannot see our coporate domain while connected internally. From home I have no problem. Our Admin has stated that I need to flush DNS. I have done so but still cannot see the domain. Any help would be appreciated.

    danbrodie@builddirect.com

  12. Matt says:
    July 18, 2006 at 5:42 PM

    Here’s what worked for me:

    1. Quit and relaunch Safari.app
    2. Safari > Empty Cache
    3. History > Clear History
    4. Quit Safari.app
    5. Launch Terminal.app and type in: lookupd -flushcache
    6. Quit Terminal.app
    7. Launch System Preferences > Network > TCP/IP > DNS Servers
    8. Enter:
    4.2.2.1 (Return)
    4.2.2.2
    9. Configure IPv6 > Off > Click “Ok”
    10. Click “Renew DHCP Lease” Button
    11. Apply Now
    12. Restart Mac and launch Safari.app again and give it a whirl

    I hope this works for you. It’s probably too much, but it’s what fixed my problem on my Quad.

    Dan from post above says that this procedure worked for him.

    Edit by Sean: The above instructions seem a bit overkill just to fix a simple DNS caching issue. The IP addresses 4.2.2.1 and 4.2.2.2 are owned by Qwest Communications. Please note that using remote DNS servers may solve your lookup issue but be slower than using local DNS servers from your own company/ISP.

  13. Justin says:
    August 1, 2006 at 11:44 PM

    I’ve tried everything and can’t seem to get my site to load. I recently changed servers, but the old IP is cached. here’s the weird thing–I used Applications > Utilities > Network Utility to test traceroute, lookup, ping, etc. and I get different results for different requests. “Lookup” find the correct IP, but Ping and Traceroute find the old IP. Any ideas what’s going on? It’s driving me crazy. I also noticed that it’s only the “www.” version of my site that’s cached, leaving the “www.” off seems to work. I can go to another computer and access the site fine though. It’s only this one computer. Lame.

  14. Syd says:
    November 16, 2007 at 2:14 AM

    For Leopard (Mac OS X 10.5), lookupd is deprecated apparently. So, use this instead:

    $ dscacheutil -flushcache

  15. Slab says:
    November 23, 2007 at 4:28 AM

    Thx Syd, you saved an old man a lot of headaches.

  16. David Janes says:
    January 2, 2008 at 5:48 AM

    Thanks folks — I have the flakiest home connection and DNS constantly (especially for gmail) getting into a state where it would let me hit sites.

  17. roger pack says:
    January 4, 2008 at 3:38 PM

    works like a charm for leopard. Thanks!

  18. Roy says:
    January 5, 2008 at 7:03 PM

    Hi, I wonder if you can help me. I’m trying to find out the names of my DNS server when I use the cat /etc/resolv.conf it says something about a LAN and gives me my IP Address. Whats that about? Cheers.

  19. Gary says:
    January 24, 2008 at 8:37 AM

    Roy,
    If it says something like this:

    mac:~$ cat /etc/resolv.conf
    domain localnet
    nameserver 192.168.1.1

    Then that probably means your router is acting as a DNS relay. Try logging into the router config pages, and the DNS settings for your ISP should be there someplace…

  20. g_face says:
    February 29, 2008 at 3:39 PM

    Justin is right, the command is now
    dscacheutil -flushcache
    for 10.5

    Thanks for this page – this solved my prob.

  21. Muthu says:
    April 14, 2008 at 9:26 PM

    It worked. Great thanks.

    10.5: dscacheutil -flushcache

  22. grateful! says:
    May 16, 2009 at 9:01 PM

    Thank you for posting this. It’s actually hard to find!

  23. W.golf says:
    June 16, 2009 at 2:16 AM

    Need help. Trying to delete DNS cache, somehow cannot access terminal.app on my G5.
    Any advice?

  24. w.golf says:
    June 16, 2009 at 12:33 PM

    Need help. I would like to delete the DNS cache but unable to access the Terminal.app on my G5.

    Any advice?

  25. Besworks says:
    June 25, 2009 at 12:18 AM

    Thank You! This was driving me nuts!

  26. David says:
    July 21, 2009 at 9:11 PM

    A LITTLE HELP PLEASE?? I went to Installous and I searched for the application “worms”. I selected the right application of the search results, and it took me to the information and version selection downloads for this app, where I selected Version 1.0. I don’t remember, but I believe there was only AppScene.org as the list of sites to touch. I touched the one cracked by “Pro” and it took me to a white screen where it told me “Please update your DNS cache.”. Now, I found this website and I tried the command, dscacheutil -flushcache, which didn’t work in Mobile Terminal.

    I copied the exact same command (dscacheutil -flushcache) into Mobile Terminal. I also tried the other command (lookupd -flushcache).

    THIS IS EXACTLY WHAT I TYPED IN MOBILE TERMINAL:
    MY-NAME:~ mobile$ dscacheutil -flushcache

    I PUSHED THE “return” BUTTON ON THE KEYPAD ANDTHIS IS WHAT CAME UP:
    -sh: dscacheutil: command not found

    I don’t know why this one, dscacheutil -flushcache, and the other one, lookupd -flushcache didn’t work.

    What can I do? (I also had a movie [torrent] prepared, and I typed in ./gettorrent the last time I went to Mobile Terminal, which was about 2 days ago. I didn’t know how to “un-prepare” it, so I just exited Mobile Terminal by pushing the Home button. I don’t know if this matters…)

    Help would be very much appreciated, thanks! :)

  27. Justin says:
    December 7, 2009 at 12:30 PM

    @W.golf ::

    I cannot recall what OS X even looked like in Tiger (10.4?) but Terminal.app should always be in :

    Macintosh HD > Applications > Utilities > Terminal.app

    If you can’t find it there or you’d prefer to try another program for the same purpose, there is one called iTerm which I used until Terminal.app got tabbing support; it’s at SourceForge:

    http://sourceforge.net/projects/iterm/

    Better a late reply than never?

    Good luck

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Categories

Archives

Blogroll

  • Development Blog
  • Documentation
  • Plugins
  • Suggest Ideas
  • Support Forum
  • Themes
  • WordPress Planet

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Pages

  • About Inert Ramblings

All content © 2012 by Inert Ramblings. WordPress Themes by Graph Paper Press