Computer >> Computer tutorials >  >> Troubleshooting >> MAC

How to Flush the DNS Cache on a Mac

Are you having trouble loading websites in your browsers? A possible culprit is your DNS cache. You can clear this cache without harming anything on your Mac, and this can potentially fix your website-loading issues.

Depending on the macOS version you use, you need to execute a particular command in Terminal to get rid of all your DNS cache content. We’ll show you how to do just that on your Mac.

Why Should You Flush the DNS Cache on a Mac?

Generally, you should clear the DNS cache when you experience DNS-related errors on your Mac. This includes any DNS error messages you see in your browsers as well as any apps you use on your Mac.

Clearing the DNS cache helps fix some browsing-related issues. This is because of how the DNS works on your computer. As you might already know, DNS translates your domain names to IP addresses. If the DNS cache gets corrupted, or there are other issues with it, that translation fails which results in interrupted browsing sessions.

Flushing the DNS cache helps fix these issues on your Mac.

How to Clear the DNS Cache on a Mac

In macOS, you can flush the DNS cache by running a command with Terminal. There are variations of this command and you need to use the one that’s appropriate for your macOS version.

Step 1. Find Your macOS Version

The first thing you need to do is to find your macOS version. This will help you decide which command to use to clear the DNS cache.

To check your macOS version, click the Apple logo in the top-left corner of your screen and select About This Mac.

How to Flush the DNS Cache on a Mac

You’ll see your macOS name as well as its version. Take note of this version as you’ll use it in the following section when you actually delete the DNS cache.

Step 2. Run a Command to Flush the DNS Cache

You’ll use a Terminal window to execute a command and flush the DNS cache on your Mac. Here’s how you do that:

  1. Open Terminal by finding it with Spotlight, Launchpad, or Finder.
  2. If your macOS version is 10.11 or later, type the following command into the Terminal and hit Enter:
    sudo killall -HUP mDNSResponder
  3. If you use macOS version 10.10, use this command to flush the DNS cache:
    sudo discoveryutil udnsflushcaches
  4. macOS 10.7, 10.8, and 10.9 users should use this command:
    sudo killall -HUP mDNSResponder
  5. macOS 10.6 owners have to run the following command:
    sudo dscacheutil -flushcache
  6. If you run macOS 10.5 or earlier, here’s the command to let you flush the DNS cache:
    sudo lookupd -flushcache
How to Flush the DNS Cache on a Mac

If you notice, each command has sudo at the beginning; this means you’ll be asked to enter your admin password before you can run a command. Make sure you have your password handy before you try and execute any of these commands on your Mac.

Does Flushing the DNS Cache Cause Any Issues?

When you flush the DNS cache, you’re only deleting the cached entries of the DNS. You won't experience any issues as a result of removing these DNS cache files.

The next time you try to connect to a site from your browser, your browser will fetch fresh entries from the DNS server. These entries will be saved in the DNS cache and the cycle will continue.

Flushing the DNS cache doesn’t harm your Mac in any way, and so you should do this without any hesitation each time you come across a DNS issue. This can actually fix many server-related domain name problems on your computer.

Besides DNS, you can clear many other cache types on your Mac as well. Clearing the cache is a quick and easy troubleshooting method for a whole range of issues.