How to Flush DNS Cache in OS X El Capitan
If you adjust DNS settings on a Mac and the changes seemingly haven’t taken effect, or perhaps you discover that a given name server address is not resolving as intended, flushing the DNS cache is often a quick resolution. Flushing DNS cache in OS X El Capitan (10.11 or later) is easily possible with a trip to the command line, though if you’ve been using Mac OS X for a while you’ll notice the syntax is different, again, from some prior releases of Mac OS. This is because Apple has re-adopted mDNSResponder after temporarily ditching it for discoveryd, so the dscacheutil command will likely be familiar to some Mac users.
Flushing DNS Cache in OS X 10.11+
This method of clearing DNS cache applies to all Macs running versions of OS X El Capitan, versioned as 10.11 or later:
- Open the Terminal application, found in /Applications/Utilities/ or with Spotlight
- At the command prompt, enter the following syntax then hit return:
- Enter the admin password when requested (required by sudo) to execute the DNS cache clearing
- When you hear “DNS Cache flushed” you know the command has been successful*
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; say DNS cache flushed
That’s it, the DNS cache will be flushed. You’ll likely want to quit and relaunch apps that are using DNS, like a web browser, for changes to carry over to apps connected to the internet.
Clearing local DNS caches is commonly required by web developers, network administrators, performing accurate detailed lookups with host, and anyone who edits the hosts file, or adjusts domain name settings for faster servers or for other purposes.
If you intend on flushing DNS caches often, a simple alias placed in your appropriate .profile can be beneficial for quick future usage:
alias flushdns='dscacheutil -flushcache;sudo killall -HUP mDNSResponder;say flushed'
Users can also cut out the say portion and split the command into several parts, though a one liner is often the easiest way to go.
sudo dscacheutil -flushcache
Then separately initiating the mDNSResponder killall command:
sudo killall -HUP mDNSResponder
Going this route will not provide any auditory feedback that the commands have been successful.
This applies to the latest versions of OS X, whereas those who are running earlier versions of Yosemite can find directions here for the same effect with a different command string, as can users of older Mac OS X releases like Mavericks and Snow Leopard, or even the dusty versions of Tiger, Panther, and Jaguar out there. On the mobile side of things, iPhone and iPad users can quickly flush DNS cache in iOS with a simple trick too.