How to flush the DNS cache on Apple Mac OSX 10.8+

Just a quick post if only to make a note of this for myself.  For years the method of clearing the DNS cache on a Mac has been

dscacheutil -flushcache

This command runs OK on OSX 10.8+ but doesn’t actually seem to clear the DNS cache.  On OSX 10.8+ the command you need is:

sudo killall -HUP mDNSResponder


Google Chrome DNS pre-cache feature.

We all love the Google Chrome browser but today I discovered one of its lesser known features – version 1.0 caches DNS locally and never seems to refresh its cache.

Normally the host operating system is responsible for turning symbolic domain names into IP addresses by querying the DNS across the Internet.  This typically adds a few milliseconds when you call up a website for the first time.  On subsequent visits the operating systems DNS cache should have remembered the IP address and it will avoid the overhead.

The designers of Chrome are  clever.  While you are reading a web page Chrome  scans the page for domain names and performs  DNS lookup’s in the background caching these in its own DNS cache.  This means that by the time you’ve read the page and clicked on a link, the DNS cache will already be populated.

Today I discovered this feature after moving a website I’ve been working on over to another web server.  I updated the DNS left it a few minutes and then did the old IPCONFIG /flushdns command and then checked the site using various browsers to make sure the site was working properly.  No problems in Firefox, IE and Safari but then I tried Chrome and found that it was still pointing to the old server.

After doing some research I found the Options > Under the hood menu and disabled “Use DNS pre-fetching to improve performance”.  After doing this you have to close down all your Chrome windows and then start it up again.  This seems to clear its DNS cache.

It looks like the current version 1.0 of Chrome does not refresh DNS entries once cached.  Hopefully Google will fix this or add an obvious “Flush DNS cache” option to the menu where you normally delete the browsers history.