Difference between revisions of "Flush DNS Cache"

From Exterior Memory
Jump to: navigation, search
(Negative Caching)
(Flushing does not help)
Line 51: Line 51:
 
=== Flushing does not help ===
 
=== Flushing does not help ===
  
I've seen a few cases where flushing does not help. In that case, I usually reboot my computer.
+
I've seen a few cases where flushing does not help.
  
 
In one of these cases, the <tt>discoveryutil udnsflushcaches</tt> command would give the following error in <tt>system.log</tt>:
 
In one of these cases, the <tt>discoveryutil udnsflushcaches</tt> command would give the following error in <tt>system.log</tt>:
Line 58: Line 58:
  
 
It seems that in this case, the command from <tt>discoveryutil</tt> never reached <tt>discoveryd</tt>.
 
It seems that in this case, the command from <tt>discoveryutil</tt> never reached <tt>discoveryd</tt>.
 +
 +
In that case, I usually reboot my computer, or <tt>killall discoveryd</tt> in the knowledge that Mac OS X launch daemon will restart <tt>discoveryd</tt>.

Revision as of 23:31, 28 October 2014

Flush DNS Cache

Mac OS 10.10 and up

discoveryutil udnsflushcaches

Mac OS 10.7 up to 10.9

dscacheutil -flushcache
killall -HUP mDNSResponder

Mac OS 10.5.2 up to 10.6

dscacheutil -flushcache

Mac OS up to 10.5.1

lookupd -flushcache

Windows

ipconfig /flushdns

Linux

Depending on your distribution:

/etc/init.d/named restart

or

/etc/init.d/nscd restart

Troubleshooting

Negative Caching

ping, or most other programs use the build-in name discovery, with build-in cache. In this case, there is a negative cache:

$ ping www.example.org
ping: cannot resolve www.example.org: Unknown host

host, dig or nslookup do not use the build-in name discovery, but always query an external name server, bypassing any cache at the local host (the name server is likely to still cache the result though).

$ host www.example.org
www.example.org has address 93.184.216.119
www.example.org has IPv6 address 2606:2800:220:6d:26bf:1447:1097:aa7

In this example, the name servers finds the DNS record, but the local host says it does not exist. This is negative caching; a previously 'not found' result is cached. In this case, it is best to flush the local DNS cache and try again.

Flushing does not help

I've seen a few cases where flushing does not help.

In one of these cases, the discoveryutil udnsflushcaches command would give the following error in system.log:

discoveryd[36369]: Basic RemoteControl com.apple.discoveryd XPC connection 0x7fa7a8590860: Connection invalid

It seems that in this case, the command from discoveryutil never reached discoveryd.

In that case, I usually reboot my computer, or killall discoveryd in the knowledge that Mac OS X launch daemon will restart discoveryd.