How to Clear the DNS Cache in MacOS Sierra or Later?
Written by Karolina Peistariene on
How to Manually Clear the DNS Cache on a Mac Computer Running macOS Sierra or Later?
DNS settings are responsible for translating domain names to Internet Protocol (IP) addresses. Without DNS servers, you would have to remember the IP address of each website. For example, rather than typing www.apple.com in the Internet browser, you would have to type 17.172.224.47 - obviously, not very convenient.
There are situations when you will need to clear DNS cache, such as to ensure that the name server responds correctly. Also, if you have made changes in the /etc/ hosts file, you must clear the DNS cache for them to take effect. This last point is not often mentioned in many guides - changes might not take effect until the DNS cache is reset.
Restarting the Mac will often clear the DNS cache. However, there are cases when a reboot is not an option. In this guide, you'll find out ways you can clear the DNS cache on your Mac.
Video showing How to Reset DNS Cache on macOS Sierra or Later?
Table of Contents:
- Introduction
- How to clear DNS cache on computers running on macOS Sierra or later
- An alternative method to reset DNS cache on Mac computers
- Video showing How to Reset DNS Cache on macOS Sierra or Later?
How to clear DNS cache on computers running on macOS Sierra or later
1. Launch the Terminal application by using Spotlight. Press Command and Spacebar, or through the Finder, go to Applications, and then Utilities.
2. Next, type the following command (if possible, copy-and-paste or type it carefully, since upper/lower case and space errors will invalidate the command): sudo killall -HUP mDNSResponder; say DNS cache has been flushed
3. Press the return key and, since you are using the sudo (superuser) permissions, enter your administrator account password to confirm the action.
4. Wait a few moments until you hear an audio alert announcing that the DNS cache has been flushed when the process completes. This will apply to the changes made to DNS settings or /etc/ host files.
An alternative method to reset DNS cache on Mac computers
In some cases, you might need to quit and relaunch any active applications using the DNS or network such as Safari, Chrome, Firefox, Opera, sFTP, SSH, and any similar tasks relying on domain name correspondence. This particular command can fail, but this is not a significant issue since an alternative command is available in newer versions (Sierra 10.12.3 and above) of macOS.
1. Launch the Terminal app.
2. In the Terminal window enter the command: sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache; say MacOS DNS cache has been cleared3. Press the return key to execute, and confirm the action with the administrator's password.
Note: this step is based on modern versions of macOS such as Sierra 10.12 and later. The methods on earlier versions vary slightly.
▼ Show Discussion