Home / How to clear the DNS cache on Mac OSX

How to clear the DNS cache on Mac OSX

DNS lookups are cached so that subsequent lookups for the same host don’t require querying an external DNS server again until the TTL expires. Sometimes you need to clear the cache, for example if you’ve changed a DNS record, and this post shows how to do it on Mac OSX.

Clear the cache using Terminal

The following command works from Max OSX 10.5 Leopard and above (at the time of writing this post it works on the 10.8 Mountain Lion which is the current version) to flush the DNS cache.

Open up Terminal, which is under Applications -> Utilities (or use Spotlight or other lauching apps to start it) and enter the following command:

dscacheutil -flushcache

You won’t get any feedback from the command; just another command line directly afterwards

Note that this will clear the dns cache of your computer only; any records currently in the DNS server you are using will remain. For example, if your router has a caching DNS server then it won’t be flushed and will still retain records until the TTL expires.

It also won’t flush the cache of your browser (if it has one) and may require a browser restart.