How to reset the DNS cache on macOS

When working on websites, you occasionally need to reset your computer’s DNS cache, especially after editing records or changing hosts. While clearing the DNS cache on Windows is easy with a dedicated command, Mac users will have to use a small workaround.

Clear your DNS cache on your Mac

To clear your DNS cache on your Mac, open Terminal, which you can find in Applications> Utilities or by searching with Spotlight, then run the following command:

sudo killall -HUP mDNSResponder

Enter Your password, if requested.

What does this command actually do? What is happening here is you are making your system clear the cache. Wikipedia explains:

That Signal SIGHUP is sent to a process when its control terminal is closed. It was originally designed to notify the process of a serial line drop (hang up). In modern systems this means Signal usually that the controlling pseudo or virtual terminal has been closed. Many daemons will reload their configuration files and reopen their log files instead of exiting when they do this Signal receive. nohup is a command to make a command do the Signal to ignore.

Of course, you don’t have to know anything else. But now you do.

There is a lot of conflicting information about this procedure on the internet. Some sites claim that in High Sierra you need to run more commands, such as: examplewhile others make this command unnecessarily long. However, as far as we can tell, the above command is actually required. So check your work.

Check if your DNS has indeed been reset

Not sure if your DNS reset actually worked? Closing your web browser before clearing the cache can help in some situations, but if that doesn’t seem to work there are two quick ways to check that your cache is empty.

The first is site specific. Enter at the terminal dig followed by the URL of the site. To the example:


In the “Responses” section of the results, you can see the IP address that your computer knows for the listed site.

If you don’t see the new IP address, you should change the DNS settings on your Mac and clear the cache again.

For a more global (not location specific) method, you can also confirm that the cache will be reset using the console, which can be found under Applications> Utilities or by using Spotlight. When your system is highlighted in the left pane, enter “mDNSResponder” in the search field, press Enter, enter “Cache Size” next to this first query and then press Enter again. Like this:

Now, with your console window still open, go back to your terminal window and run the following command:

sudo killall -INFO mDNSResponder

You should see the DNS cache size highlighted in the console window. Now run this command:

sudo killall -HUP mDNSResponder

Then run this command again:

sudo killall -INFO mDNSResponder

You should see the change in cache size in the console window. In the screenshot above, you can see that our cache size changed significantly after the commands were issued.

Related Posts