Difference between revisions of "Flush DNS Cache"

From Exterior Memory
Jump to: navigation, search
(Created page with "== Flush DNS Cache == {{Main|Flush DNS Cache}} You can explicitly flush your DNS cache. On Mac OS up to 10.5.1: lookupd -flushcache On Mac OS 10.5.2 to 10.6: dscacheut...")
 
Line 1: Line 1:
 
== Flush DNS Cache ==
 
== Flush DNS Cache ==
  
{{Main|Flush DNS Cache}}
+
=== Mac OS 10.10 and up ===
  
You can explicitly flush your DNS cache.
+
discoveryutil udnsflushcaches
  
On Mac OS up to 10.5.1:
+
=== Mac OS 10.7 up to 10.9 ===
  
  lookupd -flushcache
+
  dscacheutil -flushcache
 +
killall -HUP mDNSResponder
  
On Mac OS 10.5.2 to 10.6:
+
=== Mac OS 10.5.2 up to 10.6 ===
  
 
  dscacheutil -flushcache
 
  dscacheutil -flushcache
  
On Mac OS 10.7, dscachutil is broken and you should use a workaround:
+
=== 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 ===
 +
 
 +
<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:
  
  sudo killall -HUP mDNSResponder
+
  ping www.example.org
 +
ping: cannot resolve www.example.org: Unknown host
  
 +
<tt>host</tt>, <tt>dig</tt> or <tt>nslookup</tt> 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).
  
OSX 10.10
+
$ 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
  
sudo discoveryutil udnsflushcaches
+
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.
OSX 10.9
+
  
dscacheutil -flushcache; sudo killall -HUP mDNSResponder
+
=== Flushing does not help ===
OSX 10.7  – 10.8
+
  
sudo killall -HUP mDNSResponder
+
I've seen a few cases where flushing does not help. In that case, I usually reboot my computer.
OSX 10.5 – 10.6
+
  
sudo dscacheutil -flushcache
+
In one of these cases, the <tt>discoveryutil udnsflushcaches</tt> command would give the following error in <tt>system.log</tt>:
Windows
+
  
ipconfig /flushdns
+
discoveryd[36369]: Basic RemoteControl com.apple.discoveryd XPC connection 0x7fa7a8590860: Connection invalid
Linux (depending on what you’re running)
+
  
/etc/init.d/named restart
+
It seems that in this case, the command from <tt>discoveryutil</tt> never reached <tt>discoveryd</tt>.
/etc/init.d/nscd restart
+

Revision as of 23:24, 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.