How to Flush DNS Cache in OS X Yosemite with discoveryutil

Nov 20, 2014 - 20 Comments

Flush DNS Cache in OS X

Some Mac users may encounter situations where they need to flush DNS cache in OS X for a name server to resolve properly, or for some DNS address change to become noticed by their individual computer. This is particularly relevant for system administrators, network admins, and web developers, but there are certainly situations where other users may need to dump and reset DNS caches too, like if a user has modified the /etc/hosts file and they need the changes to take effect without rebooting the Mac.

Longtime Mac users will know that resetting DNS cache has changed in nearly every version of Mac OS X, and OS X Yosemite is no different, likely due to the discoveryd replacing mDNSResponder, and then switching back to mDNSResponder yet again. Regardless, flushing DNS cache in Yosemite remains a terminal command, but it differs slightly depending on the exact release you are using of the OS, and it actually allows you to clear either Multicast DNS or Unicast DNS, or both. You’ll probably want to clear both for good measure if you’re trying to reset all DNS caches on the Mac.

Clear DNS Cache in OS X Yosemite 10.10.4 & OS X 10.10.5

From OS X 10.10.4 moving onward to 10.10.5, including 10.11, Apple has ditched discoveryd and has replaced it (or rather, reverted back to) mDNSResponder. Thus, to clear DNS caches in OS X Yosemite 10.10.4, and 10.11 El Capitan, and presumably onward, the command string is as follows:

sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder;say cache flushed

That command flushes all DNS caches for OS X 10.10.4+.

Longtime Mac users may recall that command string is basically what worked in the release prior to Yosemite. With that said, earlier versions of OS X Yosemite before 10.10.4 will use a different command string discussed below.

Clearing DNS Caches in OS X Yosemite (10.10, 10.10.1, 10.10.2, 10.10.3)

You’ll need to use the Terminal to reset cache, you can find the Terminal app in /Applications/Utilities/ or launch it with Spotlight. To completely clear all DNS caches in the latest version of OS X, target both MDNS (Multicast DNS) and UDNS (Unicast DNS) with two different commands.

Clear MDNS Cache

sudo discoveryutil mdnsflushcache

Hit return and enter the admin password when requested.

Clear UDNS Cache

sudo discoveryutil udnsflushcaches

Again, hit return and enter the admin password when requested. Note that caches is plural with the latter command, a subtle but important syntax difference.

Flush and Reset All DNS Caches in OS X Yosemite

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.

For those wondering, OS X Yosemite has done away with mDNSResponder, so there’s no need to kill that mDNSResponder process to refresh DNS caches like in prior versions of Mac OS X.

Checking DNS Cache Details in OS X Yosemite

If you are changing or are going to change DNS, and you want to see some details about what is currently cached, you can use the following commands:

Get UDNS cache statistics:

sudo discoveryutil udnscachestats

You can also retrieve specifics about multicast DNS cache with the following:

sudo discoveryutil mdnscachestats

Both of these will offer details as to the number of DNS entries are cached, offering a report that should look like this:

UDNS Cache Stats: Cached 962 of 1750

If you run those commands before and after running the flushcache variations, you’ll find they should be reset to 0 entries cache, like so:

MDNS Cache Stats: lo0: Cached 0 of 2000

How do you know if it changed?

After you’ve flushed cache, if you want to determine if a name server or IP has actually changed you can use the ‘dig’ command with the URL like so:


dig is similar to nslookup, except that it has better output and a few more details included, included query time, the set DNS server used to access the domain, and a timestamp, all of which can be valuable when troubleshooting name server issues. By the way, if the query time for this shows up as sluggish, you should use a tool like namebench to find a faster DNS server for you, often Google DNS or OpenDNS.

Know of another DNS cache trick for the latest versions of OS X? Let us know in the comments.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS X, Tips & Tricks


» Comments RSS Feed

  1. Pat Seajack says:

    Glad to know how to dump DNS in Yosemite and Mac OS 10.10 but i”m sure it’ll be different in OS X 10.11 and OS X 10.12 now.

    Oddly enough, the old one still exists! But, doesn’t seem to do anything, right? I do this and no cache flush?

    sudo dscacheutil -flushcache

    So, I guess make an alias for the huge double-dipper MDNS and UDNS mega DNS dump that cache:

    alias resetdns=’sudo discoveryutil mdnsflushcache;sudo discoveryutil udnsflushcaches;sudo dscacheutil -flushcache;say flushed’

    Yea, that’s right, I put them all in there for good measure. Flush that cache, baby! I need this sucker to work.

    Why does Apple keep changing the DNS reset tool? Keep us on our toes?

  2. It’s good to note the venerable Unix host, dig, and nslookup commands use different resolver mechanisms than most of OS X. When troubleshooting I usually compare with ping which gives the same results as the gui apps.

    I use VPNs to customer sites daily, and often need to debug the VPN sites local DNS not being used.
    When I find the DNS resolver works by testing with the host command, I cross check the same host with ping. If the results are not alike, it’s time to flush the DNS cache.

    On a side note, the equivalent procedure with DNS flushing used to work for all hosts in a remote vpn site in previous releases, but now I find I need to flush the cache more than once to get multiple hosts working. I sure hope Appe will settle on the architecture to use for resolver and put more effort in stabilizing it 😄

  3. THANKS Paul — your flush cache tutorial was the ultimate solution for the mysterious renaming malady that befell many Yosemite users after update. Previously happy host / computer names like ‘iMac-27’ suddenly and persistently became ‘iMac-27 (2)’ regardless of terminal encantations.

    Your flush cache suggestions have allowed my machines to run happy with their proper names for over 24 hours.

    EURIKA — and THANKS.

  4. Wharf Xanadu says:

    I made the alias I like that idea.

  5. enzo treppa says:

    Thank you for this post very “to the point”. It is extremely helpful to myself who has really no knowledge of these things past os 9.. I checkout long ago. Thanks for making a simple copy paste situation. Appreciated!

  6. Casey says:

    Tried using this method, but terminal will not allow me to enter my password. Any ideas?

    • mtin says:

      Terminal allows you to enter the password, just type it anyway and hit return. Terminal will not show you the password as it is being typed, that is a security precaution.

  7. Casey says:

    Thank you for your reply, mtin. I am entering the password, but it just goes back to the main prompt.

  8. MannaBoBanna says:


    • Jin says:

      Same here. Yosemite 10.10.4

      • Carsten says:

        Same for me 10.10.4. Strange.

      • LOLer McGee says:

        If you’re using OS X 10.10.4 or later you will use the new command, which is the old command but working again in the latest release. Apple ditched discoveryd and switched back to mDNSResponder (LOL). Thus here is the command to flush caches in 10.10.4 or newer:

        sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder;say LOL

  9. Farah says:

    Thank you for this article. Very useful. Helped us get through the laptops but still the server is not responding.

  10. deezee says:

    Is there a way to create a shortcut to automatically do this when I need to rather than finding the code in notes , opening up terminal and going the through the process. Just converting over from a windows O/S and I have a shortcut on my desktop to do this, just learning how the macbook air works though so need a bit of friendly advice


  11. Nicolas says:

    I can’t believe on Apple satidfaction survey.

    I reported 10 times this problem to Apple, last ticket is AppleCare No. 788196229, they never do nothing.

    I send to him all the information they ask to me in the mail confirmation of the ticket, I continue send mails to him and they never respond.

    Up to now I switch to Chrome (because It work fine even when Safari don’t) and next step is switch to another platform.

    • DNS Master says:

      Nicolas, you can flush your DNS cache if you need to adjust DNS settings. This article details how you can flush your DNS cache in modern versions of OS X, like from 10.10 and beyond.

      You will find it has nothing to do with a survey, AppleCare, or a ticket, it is about flushing DNS cache on the Mac. It will impact all browsers, Safari or Chrome, after they have been relaunched.

  12. Quantum Leap says:

    Thanks for the info but i too get the same error . Error not resolved …

    The server at can’t be found, because the DNS lookup failed. DNS is the network service that translates a website’s name to its Internet address. This error is most often caused by having no connection to the Internet or a misconfigured network. It can also be caused by an unresponsive DNS server or a firewall preventing Google Chrome from accessing the network.

    Please Help me ..

  13. juan miquel says:

    muchas gracias me ha servido de gran ayuda

Leave a Reply


Shop for Apple & Mac Deals on

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates