How to flush DNS cache on Mac OSX

Published in: HowTo

Why Flush your DNS Cache?

In order to use the internet, we need a DNS server to resolve domain names to IP address, in the early days of the internet you DNS server address all most always used to be your ISP’s DNS server. Nowadays we have many options with a lot of free and open DNS servers, most notably Google DNS (8.8.8.8 or 8.8.4.4) and OpenDNS (208.67.222.222 or 208.67.220.220) to name a few. Alternatively, you could run your own DNS server (not recommended if you don’t know what you are doing), but it’s a topic for another article.

Most modern OS saves frequently requested DNS queries in a cache to speed up your internet experience, considering that DNS records change very rarely – it’s a good thing, but every once in a while you might need to get a most updated result while troubleshooting something – maybe your own brand new domain name. You can either wait out the TTL (time limit) of the DNS cache or clear it out yourself so that you can get a more updated result. Please keep in mind that flushing DNS cache won’t automatically give you a new result. Recently update DNS records needs time to propagate throughout the internet – which can take anywhere from 5 minutes to 30 minutes. There was a time when DNS propagation used to take upt0 24 hours, but things have sped up a lot since those days.

Flushing DNS cache on Mac OSX

On Mac OSX, open up a terminal.

For Mac OS X Snow Leopard:
sudo dscacheutil -flushcache

For Mac OS X Yosemite, Mavericks, Mountain Lion and Lion:
sudo killall -HUP mDNSResponder

For Mac OS X Yosemite v10.10 through v10.10.3:
sudo discoveryutil mdnsflushcache

As you can see on the system.log file, when DNS gets Flushed (purged):



about | pages | archive | rss