Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Flush DNS cache in Lion and Mountain Lion Network
I came across this Apple technical note this morning, which describes how to flush the DNS cache on your Mac. We have a hint for 10.5, which is also valid for 10.6, but we're not up to date.

So, as a reminder, to flush the DNS cache in Mac OS X 10.5 and 10.6, run this command in Terminal:
sudo dscacheutil -flushcache 
To do the same in 10.7 and 10.8, run this command:
sudo killall -HUP mDNSResponder 
As Apple points out, you might need to do this in the following situation:

"OS X keeps a local cache of resolved DNS queries for a time defined by the DNS server, but sometimes it may be necessary to reset the cache immediately and re-query a DNS server. For example, you might do this after an entry on the server is changed or a new entry is added."
    •    
  • Currently 3.85 / 5
  You rated: 4 / 5 (13 votes cast)
 
[82,631 views]  

Flush DNS cache in Lion and Mountain Lion | 8 comments | Create New Account
Click here to return to the 'Flush DNS cache in Lion and Mountain Lion ' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Flush DNS cache in Lion and Mountain Lion
Authored by: Ronald Lanham on Aug 08, '12 08:35:59AM

Also possible via Onyx.

Onyx > Cleaning > Internet > Delete: DNS Cache



[ Reply to This | # ]
Flush DNS cache in Lion and Mountain Lion
Authored by: petieg on Aug 08, '12 09:38:36AM

Hhmm... dscacheutil - flushcache still works in 10.8 for me. Granted it's an upgrade from Lion, but it's still there and works...



[ Reply to This | # ]
Perhaps it's a more specific method
Authored by: lullabud on Aug 08, '12 11:51:10AM

I did a clean install of 10.8 on a Mac Mini and dscacheutil exists there too. My only guess is that Apple doesn't want us clearing the entire dscache, which handles more than just DNS, so they're suggesting this alternate method that only clears DNS. If that's the case though, they should've built a -flushcache option into mDNSResponder. This new kill method seems dirty.



[ Reply to This | # ]
Old method doesn't work
Authored by: lullabud on Aug 08, '12 02:33:00PM

Interesting, I just ran into a DNS issue in 10.8 and was unable to solve it using the old style dscacheutil method. The new method fixed it.

I pinged a new server from 10.8 and was told it did not exist. I then did some work on the server and verified that its hostname was resolvable from another client. I then pinged it again from 10.8 and was told again that it did not exist. I looked it up using "host servername" and saw that it was resolvable by DNS. I did the kill -HUP trick and then pinged again, this time with success.



[ Reply to This | # ]
Flush DNS cache in Lion and Mountain Lion
Authored by: agentx on Aug 09, '12 02:05:18AM
Overall as of 10.6 mDNSresponder fully took over Unicast and Multicast DNS Queries on behalf of client processes, and maintains a cache of the replies. It was moved from Directory Services so the hint is correct and running dscacheutil on these systems will do nothing to fix DNS issues. The correct method is to restart mDNS. I have a script that most of my users have to gracefully restart mDNS. Have been using it for years to get round the poor DNS implementation on OS X. My god Apple have butchered it !

#!/bin/bash
#Script to unload and reload mDNS as it is a bit crappy
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
echo "mDNS unloaded"
sleep 5
sudo launchctl load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
echo "mDNS loaded"
sleep 5
echo "Hopefully you can get on with browsing again"
save as mdns_reload.command and place on desktop for easy cache clearing/restarting on mDNS.

Also if you run this command you will get a very detailed report in /var/logs/system.log of the state of your cache etc.

sudo killall -INFO mDNSResponder
Edited on Aug 09, '12 02:13:38AM by agentx


[ Reply to This | # ]
Flush DNS cache in Lion and Mountain Lion
Authored by: WestNab on Nov 20, '12 04:18:29AM

I have an iMac for which none of these solutions work.

$ ping xyz
PING xyz.abc.ac.uk (10.0.0.60): 56 data bytes
Request timeout for icmp_seq 0

10.0.0.60 is not the correct IP address for xyz (it was long ago). The iMac has correct DNS servers configured as well as search domains abc.ac.uk & xyz.abc.ac.uk

DNS lookup using dig of the short name fails:

$ dig xyz
... {guff with brackets that breaks html parser}
... opcode: QUERY, status: SERVFAIL, id: 48293

whereas dig xyz.abc.ac.uk succeeds with the correct results from one of the correct DNS servers. Other machines (including iMacs) on the network can ping xyz fine.

I have tried all solutions mentioned in this thread, but the same occurs.

Any ideas what's going on here? And/or how to fix?



[ Reply to This | # ]
Flush hosts file as well as DNS cache in Lion and Mountain Lion
Authored by: WestNab on Nov 21, '12 04:17:42AM

Ah, as usual it was my own fault - an entry in

/etc/hosts

file. Now edited out. All OK.



[ Reply to This | # ]
Flush DNS cache in Lion and Mountain Lion
Authored by: agentx on Nov 21, '12 08:03:33AM

I would check your hosts file if you are that way inclined to play with it.

[EDIT] OOPS just seen your post !!!

Edited on Nov 21, '12 08:04:12AM by agentx



[ Reply to This | # ]