Mac OS users who have modified their DNS settings may need to clear their DNS cache before the changes take effect. Additionally, sometimes name servers and domains may not resolve as intended if you have stale DNS cache on the Mac, another situation where resetting DNS cache can often be the solution.
We’ll show you how to flush out DNS cache in MacOS Sierra 10.12 and later.
Note: this uses the command line and thus is aimed at more advanced users. It’s fairly rare that a novice Mac OS user would need to reset their DNS cache anyway, but often just rebooting will achieve the same effect.
How to Clear DNS Cache in MacOS Sierra
- Open the Terminal application, found in the Utilities folder within Applications
- Enter the following command syntax exactly (use copy and paste if in doubt about syntax accuracy):
- Hit the Return/Enter key and enter the admin password when requested (this is necessary because of sudo privileges)
- Wait a few moments for the DNS cache to be cleared
sudo killall -HUP mDNSResponder;sudo dscacheutil -flushcache;say DNS cache has been flushed
You will get a verbal audio alert the DNS cache has been flushed when complete.
This can be particularly important if you have recently made changes to DNS servers in Mac OS and are finding the changes have not taken effect, but is also frequently used by web developers, programmers, and designers who are working with domain names or after editing the hosts file.
Though it’s not always necessary, you may need to quit and relaunch any active applications which are using DNS or networking, including Safari, Chrome, Firefox, Opera, sFTP, SSH, and other similar tasks dependent on domain name correspondence.
Rarely the above command may not work, but an alternative command is available for macOS Sierra 10.12.3 and later that adds an additional focus on a helper process as well, that syntax is:
sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache;say MacOS DNS cache has been cleared
As before, hitting return will execute the command syntax and reset the DNS caches in MacOS 10.12.4 and newer releases.
Remember, this tip is intended for modern versions of macOS including Sierra 10.12 and later. Earlier versions of MacOS often have completely different methods of resetting DNS cache as described here, though since some of the earlier releases are still in deployment it can be valuable to know those methods as well.
Have any comments or tricks to reset DNS cache in MacOS? Let us know in the comments!