If you are a network administrator, web developer or a system administrator of Mac, you may have to flush Dns Cache on macOS for quite a few reasons. Especially, if you want a name server to resolve rightly or a change in DNS address to be detected by your individual system.
Besides the above reasons, if you have altered the
/etc/ hosts file and you need the modifications to take effect minus rebooting the Mac, then you may find it necessary to dump and reset DNS caches.
How to Clear DNS Cache on Mac
- Resetting DNS cache is not the same in each version of Mac OS X. If you are a Mac user for a longer period, you may know that this process in OS X Yosemite is similar to some other older versions. This is probably due to the discoveryd replacing mDNSResponder, and then switching back to mDNSResponder yet again.
- Despite the change, flushing DNS cache remains a terminal command in Yosemite, but there is a little difference depending on the exact version of the OS you are using.
- You get to clear either Unicast DNS or Multicast DNS, or both. If you are attempting to reset all DNS caches on the Mac, then you may have to consider clearing both as a proper measure.
Flush DNS Cache in macOS Sierra or macOS High Sierra
Clear DNS cache in macOS Sierra and macOS High Sierra, you have to use a new command. Head over to this quick guide to find out how it’s done.
Clear DNS Cache in Mac OS X Yosemite or El Capitan
From OS X 10.10.4 onwards, with the inclusion of 10.11, Apple has discarded discoveryd and has substituted it with mDNSResponder. As a result, to flush DNS caches in OS X Yosemite and Mac OS X El Capitan, and most likely future releases, following is the command string:
sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder; say cache flushed
Using the above command clears all DNS caches for OS X 10.10.4 and onwards.
Being a Mac user for a longtime, you may remember that this command string essentially is what worked in the release preceding Yosemite. However, the releases of OS X Yosemite previous to 10.10.4 will employ different command string as mentioned below.
To reset cache you need to use the Terminal. Find the Terminal app in /Applications/Utilities/ or open it with Spotlight. Target both UDNS (Unicast DNS) and MDNS (Multicast DNS) with two different commands to fully flush all DNS caches in the most recent version of OS X.
Clear MDNS Cache
- OS X Yosemite and later:
sudo killall -HUP mDNSResponder
- OS X v10.10 through v10.10.3:
sudo discoveryutil mdnsflushcache
Press return key and enter the admin password when asked.
Clear UDNS Cache
sudo discoveryutil udnsflushcaches
Another time, press the return key and enter the admin password when asked. In the second command, the caches is plural, a small but crucial syntax variation.
How to Flush and Reset All DNS Caches in OS X Yosemite
If desirable it is also possible to string the two commands together. The following command will announce out loud when you clear the caches:
sudo discoveryutil mdnsflushcache;sudo discoveryutil udnsflushcaches;say flushed
Without a doubt MDNS and UDNS caches are different, but you can figure that both commands are required for functional DNS cache to really clear in OS X Yosemite. For your own requirements, if you only need to clear one or the other, it is fully possible.
It is noteworthy that OS X Yosemite has moved on from mDNSResponder. Thus, you need not kill the mDNSResponder process to refresh DNS caches as in earlier versions of Mac OS X.
In case you are using an earlier version of OS X like Mavericks, Mountain Lion, or Lion, then the commands to flush DNS will be different. Below we have mentioned Terminal commands for the earlier versions of Mac OS X, have a look.
How to flush DNS cache in OS X Mavericks, Mountain Lion, and Lion
The command below will facilitate you to reset the DNS cache in OS X v10.9.5 and earlier:
sudo killall -HUP mDNSResponder
If you are using Mac OS X Snow Leopard, then the Terminal commands for the same are below, check it out.
How to flush DNS cache in Mac OS X Snow Leopard
Just copy paste the command given below to reset the DNS cache in OS X v10.6 through v10.6.8:
sudo dscacheutil -flushcache
How to Check DNS Cache Details in OS X El Capitan or Yosemite
While you are changing DNS, if you want to know about what is cached at the time, you can use the commands as follows:
Get UDNS Cache Statistics
sudo discoveryutil udnscachestats
Additionally, you can recover details about multicast DNS cache with the following command:
sudo discoveryutil mdnscachestats
Both the above-mentioned commands offer information such as the number of DNS entries cached, providing an account of details in the following way:
UDNS Cache Stats: Cached 1250 of 1900
If you run the commands before and after executing the flushcache variations, you will discover that they must be reset to 0 entries cache, just like given below:
MDNS Cache Stats: lo0: Cached 6 of 7500
How Do You Know If Change Has Occurred
Once you clear the cache, if you wish to know whether the IP or name server has really changed, make use of the ‘dig’ command with the URL as given below:
dig and nslookup are quite similar, but with the exception that dig gives better result by including additional information. It provides details like the set DNS server used to access the domain, a timestamp and the included query time; all these details are useful when troubleshooting name server problems. If the query time in the result is sluggish, you must use a tool named namebench to get a faster DNS server, commonly OpenDNS or Google DNS.
That’s pretty much it!
Hopefully, getting rid of DNS cache will no longer be a big deal for you. Have any question? Toss it up in the comments below.
You might want to take a peek at these posts as well:
- How to Use Secure Boot on iMac Pro
- DearMob iPhone Manager for Mac and Windows
- How to Hide Purchased Apps on Mac
Found this guide helpful? Download our app and stay connected with us via Facebook, Twitter, and Google Plus to read more such articles.
The post How to Flush DNS Cache in macOS, El Capitan, or Yosemite appeared first on .