Introduction
DNS (Domain Name System) cache stores recently visited website information to speed up future connections. However, sometimes this cached data can become corrupted or outdated, causing connectivity issues, website loading problems, or preventing access to recently updated websites. Clearing your DNS cache is often the first troubleshooting step for network-related issues on macOS.
This comprehensive guide covers DNS cache clearing commands for all macOS versions from Catalina (10.15) to the latest Sequoia (15), as Apple has changed these commands multiple times over the years.
Understanding DNS Cache
When you visit a website, your Mac stores the IP address information in its local DNS cache. This cached data helps your system quickly resolve domain names without querying DNS servers repeatedly. However, when websites change their IP addresses or when DNS propagation occurs, your cached data may become stale and cause connection problems.
Common scenarios when you need to flush DNS cache include:
- Websites showing 404 errors or old content
- Unable to access recently updated websites
- DNS propagation issues after domain changes
- Network connectivity troubleshooting
- Testing website changes during development
DNS Cache Clear Commands by macOS Version
macOS Sequoia (15), Sonoma (14), Ventura (13), Monterey (12), and Big Sur (11)
For all modern macOS versions from Big Sur onwards, Apple uses a combined command approach:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
This command performs two actions:
dscacheutil -flushcache
– Clears the Directory Service cachekillall -HUP mDNSResponder
– Restarts the mDNS Responder process
macOS Catalina (10.15), Mojave (10.14), High Sierra (10.13), Sierra (10.12), and El Capitan (10.11)
For these macOS versions, use the simpler command:
sudo killall -HUP mDNSResponder
This command sends a hangup signal to the mDNS Responder process, forcing it to reload its configuration and clear the DNS cache.
Step-by-Step Instructions
Method 1: Using Terminal (Recommended)
- Open Terminal:
- Press
Command + Space
to open Spotlight - Type “Terminal” and press Enter
- Alternatively, go to Applications → Utilities → Terminal
- Press
- Execute the appropriate command:
- For macOS 11+ (Big Sur to Sequoia):
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
- For macOS 10.11-10.15 (El Capitan to Catalina):
sudo killall -HUP mDNSResponder
- For macOS 11+ (Big Sur to Sequoia):
- Enter your password:
- When prompted, type your administrator password
- Note: You won’t see the password characters as you type
- Press Enter to execute the command
- Confirmation:
- No success message will appear
- A new command line prompt indicates successful completion
- Your DNS cache has been cleared
Method 2: One-Click Script Creation
For frequent DNS cache clearing, create a simple script:
- Open Terminal and create a new script file:
nano ~/flush-dns.sh
- Add the appropriate command for your macOS version:
#!/bin/bash # For macOS 11+ (Big Sur, Monterey, Ventura, Sonoma, Sequoia) sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder echo "DNS cache cleared successfully!"
- Save the file (Ctrl+X, then Y, then Enter)
- Make the script executable:
chmod +x ~/flush-dns.sh
- Run the script anytime:
~/flush-dns.sh
Verifying DNS Cache Clear
To verify that your DNS cache has been successfully cleared:
- Check DNS resolution timing:
time nslookup google.com
- Use dig command for detailed DNS information:
dig google.com
- Test website connectivity:
ping google.com
Advanced DNS Management
Checking Current DNS Settings
View your current DNS configuration:
scutil --dns
Manually Setting DNS Servers
Change DNS servers temporarily for testing:
# Set Google DNS
sudo networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.4.4
# Set Cloudflare DNS
sudo networksetup -setdnsservers Wi-Fi 1.1.1.1 1.0.0.1
# Reset to automatic DNS
sudo networksetup -setdnsservers Wi-Fi empty
Monitoring DNS Cache Activity
Monitor mDNSResponder activity in real-time:
sudo log stream --predicate 'process == "mDNSResponder"' --style syslog
Troubleshooting Common Issues
Permission Denied Errors
If you encounter permission errors:
- Ensure you’re using
sudo
before the command - Verify your user account has administrator privileges
- Try running Terminal as administrator
Command Not Found Errors
If commands aren’t recognized:
- Verify you’re using the correct command for your macOS version
- Check for typos in the command syntax
- Ensure Terminal has proper system access permissions
DNS Issues Persist
If clearing DNS cache doesn’t resolve issues:
- Check your network connection
- Restart your router/modem
- Try different DNS servers (Google: 8.8.8.8, Cloudflare: 1.1.1.1)
- Reset network settings: System Preferences → Network → Advanced → TCP/IP → Renew DHCP Lease
- Check /etc/hosts file for hardcoded entries:
sudo nano /etc/hosts
Best Practices and Security Considerations
When to Clear DNS Cache
- After changing DNS server settings
- When experiencing website loading issues
- During website migration or DNS propagation
- For web development and testing
- As part of network troubleshooting
Security Implications
- Clearing DNS cache removes potential DNS poisoning
- Regular clearing can prevent accumulation of outdated entries
- Consider using secure DNS providers (DNS over HTTPS)
- Monitor for unusual DNS activity
Performance Considerations
- First website visits after clearing will be slightly slower
- Cache will rebuild automatically during normal usage
- Don’t clear cache unnecessarily as it serves performance benefits
Alternative Methods
Using Network Utility (Older macOS)
On older macOS versions, you can also use Network Utility:
- Open Applications → Utilities → Network Utility
- Go to the Lookup tab
- Enter a domain name and perform lookups to test DNS resolution
Third-Party DNS Management Tools
Consider these tools for advanced DNS management:
- DNS Flusher: Simple GUI application for DNS cache clearing
- Cocktail: System maintenance tool with DNS management features
- TinkerTool: Advanced system configuration utility
Conclusion
Clearing DNS cache on macOS is a straightforward process, but the specific command varies depending on your macOS version. For modern versions (Big Sur and later), use the combined sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
command. For older versions (El Capitan through Catalina), the simpler sudo killall -HUP mDNSResponder
command suffices.
Regular DNS cache management is an essential skill for Mac users, especially those involved in web development, network administration, or frequent troubleshooting. Remember that clearing DNS cache is often the first step in resolving connectivity issues, but persistent problems may require additional network troubleshooting steps.
Keep this guide bookmarked for quick reference when you need to clear DNS cache on any macOS version from 10.15 to 15, and don’t hesitate to create custom scripts for frequently performed tasks.