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 clears the cache, restarts the caching daemon, and fetches fresh DNS records. And there was much rejoicing…sudo killall lookupd lookupd -flushcache
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.
21 Comments »
Leave a comment
About Inert Ramblings
I’m too lame to update this page but just cool enough to remove the default text.
-
Recent
- Totally unsupported Ubuntu 8.04 (Hardy Heron) installer for ServerBeach RapidRescue
- Creating DOS floppies and USB thumbdrives for BIOS flashing
- Test post, ignore. Blargh.
- links for 2007-03-07
- links for 2007-02-28
- Elementary school seeks Digg’s help to collect postcards from around the US
- links for 2007-02-20
- links for 2007-01-30
- links for 2007-01-28
- links for 2007-01-27
- links for 2007-01-26
- links for 2007-01-25
-
Links
-
Archives
- July 2008 (2)
- May 2008 (1)
- March 2007 (1)
- February 2007 (3)
- January 2007 (17)
- December 2006 (9)
- November 2006 (3)
- October 2006 (5)
- September 2006 (2)
- August 2006 (1)
- July 2006 (2)
- June 2006 (1)
-
Categories
-
RSS
Entries RSS
Comments RSS
`lookupd -flushcache` works as well. No sudo required.
Comment by rentzsch | May 11, 2004
Hrm. I really should have thought of that. ;) Thanks!
Comment by Sean | May 11, 2004
*shudder*
killall scares me from my DEC Unix days. ps | grep | awk | xargs -n 1 kill, or skill if your platform supports it.
/Andrew
Comment by Andrew | May 13, 2004
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!)
Comment by Lazer | July 29, 2004
Clearing the DNS cache
Sometimes you need to flush the local DNS cache on a machine after a website moves it server. Here’s how…
Trackback by ONE/Northwest KnowledgeBase | September 24, 2004
look up there
For the past week or so, my Mac at work has been failing on initial DNS lookups, and then suceeding immediately afterwords. So basically, I key in a URL, wait a second for it to fail, and then hit the…
Trackback by takecover! | November 15, 2004
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?
Comment by ramz | February 1, 2005
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.
Comment by Sean | February 2, 2005
links for 2005-03-22
Math and Physics Applets (categories: physics applets) How to Do Anything Photographic © 2005 Ken Rockwell (categories: photography howto…
Trackback by The Room | March 22, 2005
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…
Comment by stan | February 16, 2006
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
Comment by Dan | June 20, 2006
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.
Comment by Matt | July 18, 2006
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.
Comment by Justin | August 1, 2006
For Leopard (Mac OS X 10.5), lookupd is deprecated apparently. So, use this instead:
$ dscacheutil -flushcache
Comment by Syd | November 16, 2007
Thx Syd, you saved an old man a lot of headaches.
Comment by Slab | November 23, 2007
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.
Comment by David Janes | January 2, 2008
works like a charm for leopard. Thanks!
Comment by roger pack | January 4, 2008
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.
Comment by Roy | January 5, 2008
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…
Comment by Gary | January 24, 2008
Justin is right, the command is now
dscacheutil -flushcache
for 10.5
Thanks for this page - this solved my prob.
Comment by g_face | February 29, 2008
It worked. Great thanks.
10.5: dscacheutil -flushcache
Comment by Muthu | April 14, 2008