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:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; say DNS cache flushed
- 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*
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.
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