How to flush the DNS Cache on Mac OS X

According to Apple: “OS X keeps a local cache of resolved DNS queries for a time defined by the DNS server, but sometimes it may be necessary to reset the cache immediately and re-query a DNS server. For example, you might do this after an entry on the server is changed or a new entry is added.”

Below are steps for clearing the Cache in Yosemite (10.10.x) and older.  If you have High Sierra (10.13.x) or newer, use this link to clear the Mac OS DNS Cache in High Sierra and newer.

To flush the DNS Cache on Yosemite (OSX 10.10) from terminal:
sudo discoveryutil udnsflushcaches

To flush the DNS Cache in Mavericks (10.9), Mountain Lion (10.8), and Lion (10.7), run the following command from terminal (Applications > Utilities > Terminal):  sudo killall -HUP mDNSResponder
flush DNS Cache Mac OS X

For even older Mac OS X, Snow Leopard (10.6) and Leopard (10.5), run this command in Terminal:
sudo dscacheutil -flushcache

I have found that despite clearing the DNS cache, Safari may still hold on to old records, so I usually have to quit Safari before clearing the DNS cache, or use another browser like Chrome which is not holding on to old DNS information.

network-tools.com is a useful site for testing DNS resolution from the internet, taking your machine and its DNS cache out of the equation.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.