How To flush your DNS cache in OS X

2014-10-24 13:12 PDT

If you want to do something as simple as flushing your DNS cache in Windows you pull up a command prompt and issue the following command:

ipconfig /flushdns

It is so easy to remember, and so easy to perform that it just becomes one of those things you keep in you head, for years and years after you have stopped using Windows.

For OS X, it is not so easy. In fact, it seems that Apple has done their best to make flushing your DNS cache as hard as possible. They change the necessary commands with nearly every release of OS X. In fact, from OS X 10.4 through 10.10 there have been five different sets of commands for flushing your DNS cache. It is such a common thing to need to do, it surprises me that Apple has not released a script with every version of OS X that issues the convoluted command for you. Several years ago I decided to solve this problem for myself, but with Yosemite being the latest in “change for the sake of change” I thought it might be helpful to make this available here:

This script will first determine what version of OS X you are running and then launch the appropriate commands to flush your DNS cache… Super easy! Just drop it in your PATH, execute it like so:

``` $ flushdns