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.

28 thoughts on “Mac OS X – Clearing DNS Cache”

  1. *shudder*

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


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

  3. Pingback: takecover!
  4. 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?

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

  6. Pingback: The Room
  7. 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’

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

    [email protected]

  9. Here’s what worked for me:

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

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

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

    $ dscacheutil -flushcache

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

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

  14. Roy,
    If it says something like this:

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

    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…

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

    Thanks for this page – this solved my prob.

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

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

    Any advice?

  18. 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 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).

    MY-NAME:~ mobile$ dscacheutil -flushcache

    -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! 🙂

  19. ::

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

    Macintosh HD > Applications > Utilities >

    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 got tabbing support; it’s at SourceForge:

    Better a late reply than never?

    Good luck

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.