Introduction
DNS cache (Domain Name System Cache) is temporary storage where macOS saves the results of domain name resolution (e.g., example.com → IP address). This speeds up access to frequently visited websites. However, if DNS records change (for example, when a site is moved to a new server) or become invalid, the cache may contain outdated data, leading to "site not found" errors or connections to the wrong IP. Flushing the DNS cache forces the system to request up-to-date records from DNS servers, which often resolves network issues without requiring a reboot.
Requirements
Before following the instructions, ensure that:
- You have macOS 10.10 (Yosemite) or newer installed. Commands differ for older versions (OS X 10.9 and earlier), but such systems are rarely used today.
- You have a user account with administrator privileges (to use
sudo). - You have access to Terminal (the built-in application).
Step-by-Step Instructions
Step 1: Open Terminal
Terminal is the macOS command line interface used to flush the cache. There are several ways to open it:
- Press Cmd+Space (Spotlight), type Terminal, and press Enter.
- Open the Utilities folder via Launchpad or Finder (Go → Go to Folder → /Utilities) and launch the Terminal application.
Step 2: Flush the DNS Cache
In the open Terminal, enter the following command and press Enter:
sudo killall -HUP mDNSResponder
What this command does:
sudo— executes the command with superuser privileges (an administrator password will be required).killall— sends a signal to all processes with the specified name.-HUP— the hangup signal (SIGHUP), which forces the process to reload its configuration and clear the cache.mDNSResponder— the system daemon responsible for DNS name resolution in macOS starting with version 10.10.
After entering the command, the system will prompt for the administrator password. Type the password (characters are not displayed as you type) and press Enter. If the password is correct, the command will execute instantly and return the command prompt (e.g., MacBook-Pro:~ user$).
⚠️ Important: Ensure you type the command exactly as shown. Typos (e.g.,
mDNSresponderwith a lowercase 'r') will result in a "No such process" message.
Step 3: Verify the Result
To confirm the DNS cache has been flushed, perform one of the following checks:
- Browser: Try opening a website that previously failed to load due to a DNS error (e.g., displayed "Could not find server").
digcommand (if installed, e.g., via Homebrew):
Thedig example.comANSWER SECTIONshould display the current IP address. If you knew the old IP (e.g., from a previous check), compare it—it should have changed if the DNS record was updated.pingcommand:
If packets are sent and replies are received (e.g.,ping -c 4 example.com64 bytes from 93.184.216.34), name resolution is working correctly.
💡 Tip: Some applications (Chrome, Firefox) have their own DNS caches. If the problem persists, close and reopen the browser or clear its cache in the settings.
Potential Issues
- "No such process" error: This means the
mDNSResponderprocess is not running. It is normally always active. Try restarting your Mac and repeating the command. If the issue continues, check if you are using third-party utilities that might stop system services. - Permission denied error: Ensure you are using
sudoand entering the password correctly. Also, verify that your user account is part of the administrator group (System Settings → Users & Groups). - Issue not resolved after flushing: The problem might not be with the macOS cache but with network settings, DNS servers, or third-party software (firewalls, antivirus, AdGuard). Check DNS settings in System Settings → Network. Also, try restarting your router and running
sudo ifconfig en0 down && sudo ifconfig en0 up(replaceen0with your network interface if necessary). - Command doesn't work on very old macOS versions: If you are on macOS 10.9 (Mavericks) or earlier, use the command
sudo dscacheutil -flushcache. However, for modern versions (10.10 and later),sudo killall -HUP mDNSResponderis recommended.