Flushing the DNS cache on a Mac clears the stored records of recent domain name lookups, forcing your system to query DNS servers fresh. This is useful after changing DNS settings, troubleshooting connection errors, or when a website loads incorrectly. The process is quick and requires only a Terminal command.
What You’ll Need
- Access to the Terminal app (found in /Applications/Utilities/ or via Spotlight)
- Administrator (admin) account password, as the command uses
sudo
Step-by-Step
- Open Terminal. Click the Spotlight icon (magnifying glass) in the menu bar, type “Terminal” and press Return. Alternatively, go to Finder > Applications > Utilities > Terminal.
- Check your macOS version. Click the Apple menu () in the top-left corner and select “About This Mac.” Note the version number (e.g., macOS 14 Sonoma, macOS 13 Ventura). The command differs slightly by version.
- Run the appropriate command. Type the command below for your macOS version and press Return. You will be prompted for your login password. As you type, the password will not appear on screen—this is normal.
For macOS Sonoma (14), Ventura (13), Monterey (12), Big Sur (11), Catalina (10.15), Mojave (10.14), High Sierra (10.13):
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
For macOS Sierra (10.12) and earlier (El Capitan 10.11, Yosemite 10.10, etc.):
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Note: The same command works for all recent versions. If you are on an older system (pre-10.10), you might use sudo killall -HUP mDNSResponder alone, but that is rarely needed today.
- Wait for the command to finish. The command usually completes in a few seconds. If it succeeds, you’ll see no output or just a new prompt line. If you see an error like “Could not flush the DNS cache,” check the troubleshooting section below.
- Verify the flush (optional). To confirm the cache is cleared, you can run
sudo dscacheutil -cachedump -entries Hostand see that the output is empty or minimal. This step is not required but helps if you want to be sure.
Common Mistakes
- Using the wrong command for your macOS version. While the command above works for most modern Macs, older versions (pre-10.10) may need a different command. Always check your version first.
- Forgetting
sudo. The command requires admin privileges. Withoutsudo, you’ll get a “permission denied” error. - Typing the password incorrectly. Since the password is not shown, a typo will cause “Sorry, try again.” You get three attempts before the command fails.
- Expecting immediate results. Flushing the cache does not guarantee a website will load instantly; it only clears local records. Your ISP or network may still cache DNS, and propagation of new DNS records can take time.
Tips
- Use the exact command. Copy and paste the command from this guide to avoid typos. In Terminal, you can paste with Command+V.
- Run the command after changing DNS servers. If you switch to a public DNS like 8.8.8.8, flushing ensures your Mac uses the new server immediately.
- Consider restarting your router. Sometimes the DNS cache is on the router, not just your Mac. If flushing doesn’t help, power-cycle your router.
- Use the “About This Mac” window. If you’re unsure of your macOS version, this window shows it clearly. The command is the same for all versions from 10.10 onward, so you only need to worry if you’re on an ancient system.
Troubleshooting
“Could not flush the DNS cache” error. This usually happens on older macOS versions (pre-10.10). If you’re on El Capitan or later, ensure you typed the command exactly as shown, including the semicolon and space. Try running sudo dscacheutil -flushcache alone, then sudo killall -HUP mDNSResponder separately.
“Operation not permitted” or “Permission denied.” This means you didn’t use sudo or your user account is not an admin. To check, go to System Settings > Users & Groups and see if your account has “Allow user to administer this computer” checked. If not, log in as an admin or ask the admin to run the command.
Terminal says “command not found.” This is unlikely on a standard Mac, but if it happens, you may have a corrupted shell environment. Try opening Terminal from the Utilities folder directly, or restart your Mac and try again.
Flush worked, but the website still loads incorrectly. The DNS cache may be cleared, but your browser has its own cache. Hard-refresh the page (Shift+Command+R) or clear your browser’s cache. Also, check if the issue occurs on other devices—if so, it’s a network-wide problem, not your Mac.
You’re prompted for a password but can’t type. This is normal—the Terminal hides your input. Type your password and press Return, even though nothing appears.
Frequently Asked Questions
Q: How often should I flush the DNS cache?
A: Only when you encounter DNS-related issues, such as a site not loading or showing an old version. There’s no need to flush regularly.
Q: Will flushing DNS cache speed up my internet?
A: Not directly. It can resolve issues where a cached IP is outdated, but it doesn’t increase bandwidth or latency.
Q: Is it safe to run this command?
A: Yes, it’s a standard macOS command. It only clears temporary DNS records and doesn’t affect other data.
Q: Do I need to restart my Mac after flushing?
A: No, a restart is not necessary. The command takes effect immediately.
Q: What is mDNSResponder?
A: It’s the macOS daemon that handles DNS and mDNS (Bonjour) lookups. Sending it a HUP signal resets its cache.
Q: The command works but I still get a “server not found” error. What now?
A: Try a different DNS server (like 8.8.8.8) in System Settings > Network > Wi-Fi > Details > DNS. If that fails, check your internet connection or contact your ISP.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Jenkins vs GitHub Actions: Which CI/CD Fits Your Team?
- Turn Off Backup Encryption in iTunes?
- Campus Tech Innovation Hubs: What They Are
- Poco C51 Airtel Prepaid Locked Variant India?
- Shared VPS Hosting: Is It Better?
- Disk Defrag Pro: What It Does and Whether You Need It