Mac OS X persistently maintains a DNS cache after connecting to a site or accessing a domain (hostname). This can produce errors when accessing resources with updated DNS in web browsers and E-mail (or any other Internet program you may be using.)
To reset the DNS cache on a Mac, you need to enter a Terminal command on your Mac.
Enter this command into the Terminal window:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
and then press Enter.
Type your system password, and press Enter again.
– Your DNS cache will be reset, but there will be no message to that effect in the Terminal. When a new line appears, it indicates the command has been carried out.
NOTE: This command only works in macOS El Capitan and newer. If you have an older version of macOS, se below for the correct command.
How to Flush DNS in Older Versions of macOS
Older versions of macOS use different Terminal commands to flush the DNS. However, you start by opening a Terminal window regardless of which macOS version you’re using.
Here are the commands to flush DNS in each version of macOS:
- El Capitan and newer: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
- Yosemite: sudo killall -HUP mDNSResponder
- Lion, Mountain Lion, and Mavericks: sudo dscacheutil –flushcache
- Snow Leopard: sudo lookupd –flushcache
- Tiger: lookupd –flushcache