Difference between revisions of "Flush DNS Cache"

From Exterior Memory
Jump to: navigation, search
(Negative Caching)
Line 38: Line 38:
 
<tt>ping</tt>, or most other programs use the build-in name discovery, with build-in cache. In this case, there is a negative cache:
 
<tt>ping</tt>, 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 www.example.org
 
  ping: cannot resolve www.example.org: Unknown host
 
  ping: cannot resolve www.example.org: Unknown host
  

Revision as of 23:25, 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 that case, I usually reboot my computer.

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.