Clear Local DNS Cache in Mac OS

How to Clear Local DNS Cache in Mac OS?

Clear Local DNS Cache in Mac OS

What is a DNS Server?

If you need to call up an internet page on the World Wide Web, you must have an IP address of the server on which the data of the page is present. But only the domain name is visible and also easily remembered by humans but when it comes to IP address, it’s too hard to remember the sequence of numbers that forms the basis of online communication. All the domains are associated with their particular IP addresses.

DNS servers are used to convert the domain names into IP addresses which can be processed by the computer systems.

What is DNS Cache?

Lcoal DNS CacheDNS cache is a temporary storage of the information about previous DNS lookups by a computer’s operating system. By keeping this local copy of DNS will allow your browser/OS to load the website faster.

If you want to visit abc.com, your browser asks your router for the IP address. The router has a DNS server address stored so it asks the IP address of that hostname. The DNS server finds the IP address belongs to abc.com and then the browser will load the appropriate page. This is the same thing that will happen for every website that you visit.

DNS cache stores the IP address of every website that you visited previously. So if you visit the website next time, the browser can find it quickly and will allow a faster connection.

Reasons for clearing the cache

DNS cache will allow a faster connection even though we need to clear this cache for a few reasons such as,

  • Security – By the DNS cache, the one who is having access to your computer can able to track the websites that you have visited.
  • Clear bad connections – DNS cache might have a bad IP connection due to some reasons which will get lumped in with the good ones. And also there may be a chance of IP change of the website that you previously visited.
  • Remove Old DNS data – Suppose if you have changed your DNS and the cache is full of previously visited websites from your old DNS, then the browser will load from that cache, not from the new Domain Name System.

How to clear DNS cache in Mac OS?

Below I have mentioned the commands for flushing the DNS cache through terminal.

Go to Applications -> Utilities -> Terminal

Run the following commands according to your versions,

MacOS 10.10.1, 10.10.2, and 10.10.3
  • sudo discoveryutil mdnsflushcache
MacOS® 10.10.4 and above
  • sudo killall -HUP mDNSResponder
MacOS 10.5 and 10.6
  • sudo dscacheutil –flushcache
MacOS 10.7, 10.8, and 10.9
  • sudo killall -HUP mDNSResponder