Flushing AKA erasing a DNS cache in a Macintosh computer could become necessary for multiple reasons – none of them seemingly involve a regular computer user who only uses their Mac for internet surfing, media consumption, and some office works. However, one who is a network administrator or an advanced level computer user interested in configuring their network on their own may often end up with a messed up DNS host file in the local Mac storage and flushing the DNS file becomes imminent. Name servers often don’t resolve right due to having incorrect parameters in the local DNS file and resolving that also needs flushing of the DNS in a Mac.

flush dns cache on mac

Flush DNS Cache on Mac – Why Do you need to Do that?

DNS stands for Domain Name System or Servers. Whenever a website name is typed into a web browser’s address field, the address is converted into the respective IP addresses of their redirecting servers. The internet works on IP addresses and not domain names directly, thus the conversion is necessary. Although the internet consists of plenty of DNS servers in different hierarchies to make the IP to domain name conversion easy and fast, yet the local DNS host file plays a significant role in making the whole process fluid and error free. Flushing DNS host file will make any error to the DNS Cache file resolve.

How to Flush DNS Cache on Mac

Similar yet the process varies across different platforms of the Mac OS X. The changes have happened mostly in OS X 10.10.4 and onwards.

Flush DNS Cache on Mac OS Sierra, Yosemite or El Capitan: In any of these two Mac operating systems, the clear DNS cache terminal command is:

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

flush dns mac
Use Terminal to flush dns cache on Mac

This command tends to work on OS X 10.10.4 and above. For the OS versions prior to that, use the commands below.

Flush DNS cache on Mac OS prior to 10.10.4: To clear the DNS cache in these Mac OS versions, clearing the MDNS cache and UDNS cache individually is needed. The terminal commands for this case are:

sudo discoveryutil mdnsflushcache
sudo discoveryutil udnsflushcache

In both of the cases, after entering the Enter button Mac OS would ask for the admin password.

However, if you don’t want to initiate these commands individually then type in the following:

sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcache; say flushed

This clears both the MDNS and UDNS caches together.

Flush DNS Cache on Mac OS X 10.9.5 and Older: The command is different; as following:

sudo killall –HUP mDNSresponder

Works in Mac OS X Mavericks, Mountain Lion, and Lion.

Flush DNS Cache on Mac OS X Snow Leopard (10.6 through 10.6.8): The command for the selected versions of Mac OS X is:

sudo dscacheutil –flushcache

Verify if the DNS Cache is Flushed

Using the ‘dig’ command in terminal, you would be able to see whether the DNS cache flushing has turned out to be successful or not. For example, type:

dig unlockboot.com

Now check if the DNS server sets that are being used are sluggish or smooth. Sluggish would mean the DNS flushing hasn’t worked well.

Conclusion: Terminal is a wonderful tool for the Mac users. As long as you know the appropriate commands, you could easily flush the DNS Cache in a Macintosh computer.

  • FourPlants

    If you need to view the DNS cache on macOS Sierra, this is what worked for me: sudo killall -INFO mDNSResponder