How To Reset Your DNS Cache

If you are having trouble accessing a website, it could be because of a problem with your DNS cache. To reset your DNS cache on your Mac, you need to enter a command using the Terminal. In most cases, this will work, especially if you are using macOS Sierra, High Sierra, or Mojave. Earlier versions of OS X may need some additional commands as well.
Video Transcript / Captions
Closed captioning for this video is available on YouTube: How To Reset Your DNS Cache.

Hi, this is Gary with MacMost.com. MacMost is brought to you by the more than 300 people that support it through its Patreon Campaign. Find out how you can become part of that at macmost.com/patreon.

So today let's take a look at flushing your DNS Cache. Now, what is a DNS cache? Well when you go to a website you usually type the name of the website like macmost.com or apple.com. DNS is a service where the name is then matched with a number, an address, which is usually a series of four numbers that shows where the server is that has the information that you want. So while you may see names like macmost.com or apple.com actually what your browser wants is a series of numbers. DNS, domain name servers, are the way that the names are translated into numbers.

Now every time you go to a website it has to do that lookup. It has to look up the name and see what the numbers are. A DNS cache is basically going to keep that around so it doesn't have to do the lookup every time. After all when you go to a website, like perhaps a newspaper website say, and it has tons of images and ads and all sorts of things. There could be elements from all sorts of different domains there. It may have to do a dozen or more lookups on different domain names. So instead of doing a lookup every time it just remembers those and saves those in a cache.

Now typically you never have to worry about DNS cache. Everything will just work fine and that's true of most users most of the time. However every once in awhile a domain name will update and your cache will be old. This is particularly true if you're a developer and you're working with new websites that are moving around in different servers and things like that. So every once in awhile you have to flush the DNS cache. So let's look at how to do that.

This can solve a variety of problems. So you may end up in a situation where you're having an issue getting to certain websites. Like say you can't get to a particular website anymore but other websites seem to work. Sometimes flushing your DNS cache is the key to solving that. In order to flush you need to go into the Terminal. So I'm going to search for and look for Terminal and then I'm going to use this command. Now if you search around and try to figure out how to flush your Mac DNS cache you're going to come up with a bunch of different answers. So I'm going to show you all the different answers because it really doesn't hurt to try some of these.

The main one, especially if you're using Sierra, High Sierra, or Mojave is simply to use this basic command here and it basically kills and restarts the DNS responder which will then clear the cache. This sudo in front of it is basically saying that in order to use this command you need to enter your password. So you have to have a regular Mac account, an Admin account, in other words and use your admin password. The same password you use to log into your Mac after you reboot it.

So I'm going to use this. Then I'll enter my password and hit return and that's it! In most cases, especially Sierra and newer, that's all you need to do. Now your DNS cache has been flushed. For good measure you may want to restart Safari and then see if the website you're having trouble getting to now works.

Now there are some other commands you can use especially if you're using older versions of Mac OS. Different websites tell you different things. Say if you're using Yosemite or El Capitan, you know, do this or that. Always use this command. This command here is one that is required for resetting DNS cache no matter what version of Mac OS you're using as long as it's somewhat recent. But also this one as well so you may want to try that. Notice it doesn't ask me the password because I just entered it. So it knows that.

There is a third command that sometimes, particularly for Yosemite, is needed. Now notice how, even though I'm using Mojave, it was fine with all of those commands. So it didn't really hurt for me to do all three of them. Now that I've entered all three of them in I can be sure, 99% sure, that I've cleared my DNS cache and I can try to see if my problem has been resolved.

For macOS Mojave, High Sierra or Sierra, all you should need is this one line:
sudo killall -HUP mDNSResponder

For earlier versions of OS X, you may also need these lines:
sudo killall mDNSResponderHelper
sudo dscacheutil -flushcache

Comments: 5 Responses to “How To Reset Your DNS Cache”

    Linda Niebanck
    3 weeks ago

    I do have trouble accessing websites because a long string of letters/numbers/etc. just can’t load. I can’t follow your directions, however. Can you list them clearly for me? I did find (accidentally) Treminal. Then what?

    Linda Niebanck

    3 weeks ago

    Linda: I have the lines for you to copy and paste right below the video. But if your problem is with complicated URLs, this won’t help. DNS only deals with domains, not the pages.

    Judy Eastwood
    3 weeks ago

    I have this very problem right now with one website only. I have spoken with Apple Care, with the company whose website it is, and with my ISP. No luck with any of those. I just reset my DNS cache as you described and still no luck. Any other ideas?

    3 weeks ago

    Judy: Maybe your ISP is blocking them? Have you tried a different browser? Different device?

    Narelle
    3 weeks ago

    I am running El Capitan,, and got this response?

    Narelles-iMac-2015:~ nar311$ sudo killall -HUP mDNSResponder

    WARNING: Improper use of the sudo command could lead to data loss
    or the deletion of important system files. Please double-check your
    typing when using sudo. Type “man sudo” for more information.

    To proceed, enter your password, or type Ctrl-C to abort.

    Password:

    You didn’t mention about this message.. should i proceed?

Leave a New Comment Related to "How To Reset Your DNS Cache"

:
:
:
0/500 (500 character limit -- please state your comment succinctly and do not try to get around this limit by posting two comments)