Website Help
How do I flush the DNS cache on my Mac OS?

How do I flush the DNS cache on my Mac OS?

The Domain Name System (DNS) is the distributed network of servers that systematizes domain names and their relevant Internet Protocol (IP) addresses. Respectively, a DNS cache is a local catalog, which contains the records of a computer’s search requests history. Its substantial purpose is to ensure fast and reliable web searches.

Like every internet-connected device, your Mac stores cached DNS records. However, sometimes this may cause connectivity and security issues for you. Therefore, you need to know how to flush the DNS cache on your MacOS.

In this article, we will elaborate on what a DNS cache is, why you should clear it, and how to flush DNS cache on your macOS.

The DNS cache contains the history of the domain translations into IP addresses for websites you have previously visited from your computer.

As this information is stored on a local level in your operating system (OS), the lookup will be completed faster. Thus, the DNS cache serves as an accelerator of the DNS lookup process. Without it, your OS would need to query the DNS server every time, which increases the DNS lookup latency.

How does it work?

Fundamentally, when you are accessing a website, your browser is asking your OS for the IP address. Then, your OS is spawning a request for a DNS lookup.

During the DNS lookup, the domain name is resolved to an IP address. Then the computer’s OS stores the received resource records based on their TTL.

The Time-to-Live (TTL) determines for how many seconds the DNS client can be caching a record. When the TTL expires for a DNS record, an updated one has to propagate globally. That is when the DNS lookup process begins anew.

The OS uses a DNS client ( Stub Resolver) to handle all DNS lookups. The resolver first checks the DNS cache. If the website has been accessed before, the OS will complete the DNS lookup locally instead of querying the DNS server. In this way, the DNS cache expedites the process and thus, the content you are looking for will be displayed faster.

DNS cache

Why should I do a DNS flush on my Mac?

The most common reason to force a DNS cache flush is to update your device’s DNS cache records. You should do this when dealing with DNS errors on a website you are trying to access. You should also do that to protect your networking history and prevent DNS cache poisoning.

DNS propagation

Since the DNS propagation may take anywhere between 24-72 hours, your cached data may be out-of-date. This can result in issues with website access, or sites being displayed with old content. Clearing your browser cache may help with such problems; however, it may not be sufficient. For example, if you have recently changed the DNS records for your domain name, these changes may not have propagated globally just yet.

That is when flushing the DNS cache comes into place. By doing this, you will be prompting your computer to update the DNS records in its DNS cache. Hence, if you try to reach your website afterward, your browser will be querying the DNS server for the latest DNS records information.

DNS errors

Occasionally, you may see a “DNS Server Not Responding” error when trying to reach a site. However, the domain or upstream service provider may not be experiencing DNS outages at that moment. In such cases, the problem is most likely at the client’s end. In this case, flushing DNS cache may resolve the issue.

Network security

While you are browsing the internet, your MacOS is collecting DNS cache of your search history. However, your browsing history may get into the hands of mal-intended web users or data collectors. To keep this information private, it is essential to frequently flush DNS cache.

DNS poisoning ( DNS spoofing)

DNS poisoning, a.k.a DNS spoofing, is a cybersecurity threat that allows hackers to manipulate your DNS cache records. In this type of attack, the hackers modify the DNS cache records with a spoofed DNS record. In this way, they may redirect you to fraudulent websites with the aim to steal your sensitive information or infect your device with malware.

DNS poisoning

Thus, you should clear the DNS cache on your MacOS often to reduce the chance of such attacks.

Nonetheless, if your browser starts redirecting you to crooked websites, you should also Scan your Mac for malware.

Is it safe to flush the DNS cache on Mac?

Your Mac’s DNS cache is regularly flushed without your participation due to the DNS records TTL. Still, if you are in any of the situations described above, you will need to force your Mac OS to flush DNS.

A Mac DNS flush is not only safe, but it can also improve your device’s security, help with connectivity issues and expedite DNS record propagation.

How to flush DNS on Mac?

The latest Mac OS version is Monterey. To flush your MacOS Monterey, follow the steps below.

  • Load the Terminal app on your Mac through the SpotLight Search bar by pressing the keys Cmd + Space.
Find Terminal in MacOS
  • When you open the Terminal, type the following command:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  • You will be prompted for your Mac password. You should have in mind that you will not see the inserted password characters.
  • Press Enter to submit your password and finish the process.

Keep in mind that no output will be shown on the command line. Instead, a new line will appear indicating that the DNS cache flush is completed.

How to flush the DNS cache on MacOS X and older MacOS versions

Older MacOs versions work with different DNS cache flush commands and you can find them indexed below.

  • For MacOS Sierra run any of the following commands to reset the DNS cache:
sudo killall -HUP mDNSResponder


sudo dscacheutil -flushcache
  • In Mac OS X 10.10 Yosemite & El Capitan
  • In OS X v10.10.4 flush DNS
sudo killall -HUP mDNSResponder
  • In OS X v10.10 through v10.10.3
sudo discoveryutil mdnsflushcache
  • In OS X 10.9 Mavericks
dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  • In OS X Mountain Lion or Lion (10.7 and 10.8) open the Terminal from Applications → Utilities and type the following command:
sudo killall -HUP mDNSResponder
  • In Mac OS X 10.6 and 10.5
sudo dscacheutil -flushcache
  • In Mac OS X 10.4 And Below, use the following terminal command:
lookupd -flushcache

How often should I flush the DNS cache on Mac?

Clearing your local DNS cache should be done on a regular basis. It ensures consistent web access and helps with network security. Although there is no particular period for resetting the DNS cache, you should flush it systematically.

Overall, resetting the DNS cache on your MacOS is beneficial when dealing with DNS errors, DNS propagation, and network security.

Share This Article