How to Reset the DNS Cache on Mac OS X

It doesn’t happen very often for regular users, but sometimes a website or service needs to change their IP address and your computer’s local cached entry is incorrect. When you are a server administrator or programmer, this happens all the time.

You can easily reset the DNS cache in Windows with the ipconfig /flushdns  command, but on OS X things are a little different. Open up a Terminal and type in the following:

sudo killall -HUP mDNSResponder

Note: you will need to enter your password each time you do this because it requires administrator-level access.

What’s actually happening here is that you are using the killall command to send the SIGHUP message that tells the DNS lookup service to flush the cache. To understand more about how this works, Wikipedia explains:

The SIGHUP signal is sent to a process when its controlling terminal is closed. It was originally designed to notify the process of a serial line drop (a hangup). In modern systems, this signal usually means that the controlling pseudo or virtual terminal has been closed. Many daemons will reload their configuration files and reopen their logfiles instead of exiting when receiving this signal. nohup is a command to make a command ignore the signal.

Obviously you don’t need to know all of the rest of that. But now you do.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.