A lot of OS X Yosemite users are complaining that dscacheutil is not helping with clearing DNS cache. Here is quick guide to try with discoveryutil.
To completely clear all DNS caches in OS X Yosemite, target both MDNS (Multicast DNS) and UDNS (Unicast DNS) with two different commands.
Step 1. Open Terminal.app
Step 2. Insert this command to terminal to
Clear MDNS Cache
sudo discoveryutil mdnsflushcache
Hit return and enter the admin password when requested.
Step 3. Insert this command to terminal to
Clear UDNS Cache
sudo discoveryutil udnsflushcaches
Hit return and enter the admin password when requested.
Note that caches is plural with the latter command, a subtle but important syntax difference.
You can also string the above two commands together if you want, the following will even verbally announce when the caches have been cleared.
sudo discoveryutil mdnsflushcache;sudo discoveryutil udnsflushcaches;say flushed
Indeed MDNS and UDNS caches are different, but I’ve found that for functional DNS cache to actually clear in OS X Yosemite both commands are necessary. It’s entirely possible that you only need to clear one or the other for your own needs.
jarjar says
nothing happens when I paste “sudo discoveryutil mdnsflushcache” into terminal..
Shinmaikeru says
With Yosemite 10.5.5, editing the hosts file has no effect, and the command you give above returns just “sudo: discoveryutil: command not found”.
You can’t do web dev if you cannot use the hosts file as a local DNS override. Do you have a solution?
iHash says
Apple remove discoveryutil in Yosemite 10.10.4, you need to use dscacheutil -flushcache
https://www.ihash.eu/2014/06/clear-dns-cache-mac-osx-10-10-yosemite/
Nate says
Editing hosts file is not the same thing as clearing dns cache. With hosts file you redirect address to another IP, with clearing dns cache you clean your local copy of dns entries.
IF you are referring to osx leopard 10.5 command for clearing dns cache is “dscacheutil -flushcache”
Shinmaikeru says
Thank you. With 10.10.5, they went back to dscacheutil -flushcache. So only 10.10.4 is different. Crazy. Thanks again.