← Back to Home

How to Clear DNS Cache on Linux, Mac, and Windows

How to Clear DNS Cache on Linux, Mac, and Windows

Posted by NetworkWhois on

DNS Cache Flushing: The Right Way on Every OS

Nothing wastes time like troubleshooting DNS issues with a stale cache. Here's exactly how to clear it on any system - and verify your records are actually correct afterward.

Pro Tip: Always verify DNS records after flushing cache using our DNS lookup tool to confirm you're getting fresh results.

Why You Need to Flush DNS

Your system caches DNS to speed up lookups, but this causes problems when:

  • You've changed DNS records (A, MX, CNAME)
  • Migrating servers or services
  • Troubleshooting "can't reach site" errors
  • Seeing outdated IP addresses

Clearing DNS Cache on Windows

Windows 10/11 (Command Prompt)

ipconfig /flushdns

Windows 7/8

ipconfig /flushdns
netsh int ip reset

PowerShell (All Versions)

Clear-DnsClientCache

Flushing DNS on macOS

macOS Ventura (13+) and Later

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

macOS Monterey (12) and Earlier

sudo killall -HUP mDNSResponder

For Legacy macOS (10.10 and below)

sudo discoveryutil mdnsflushcache
sudo discoveryutil udnsflushcaches

Linux DNS Cache Clearing

Systemd-Resolved (Ubuntu/Debian)

sudo systemd-resolve --flush-caches
sudo systemctl restart systemd-resolved

NSCD (Name Service Cache Daemon)

sudo systemctl restart nscd

DNSMasq

sudo systemctl restart dnsmasq

No Cache? Check Live DNS

Many Linux distros don't cache by default. Verify with:

dig example.com | grep "Query time"

How to Verify Your DNS is Really Updated

After flushing cache:

  1. Check records with our DNS lookup tool
  2. Compare against your local results
  3. Test from multiple locations using different ISPs

Example: If you changed your A record, verify both the old and new IPs no longer appear anywhere.

When Flushing Isn't Enough

If you're still seeing stale records after clearing cache:

  • Check TTL values with our DNS checker (high TTL = longer cache)
  • Restart your browser (Chrome keeps its own DNS cache)
  • Reboot your router (consumer gear often caches badly)
  • Wait for propagation (up to 48 hours for global changes)

Advanced: Forcing Specific DNS Results

Sometimes you need to override cache entirely:

# Linux/macOS
dig @8.8.8.8 example.com

# Windows
nslookup example.com 8.8.8.8

This bypasses local cache and queries Google's DNS directly.

Security Note: After flushing cache, verify your DNS resolver hasn't been hijacked using our IP WHOIS tool to check for suspicious networks.

Automating DNS Cache Maintenance

For sysadmins managing multiple systems:

# Linux/macOS cron job (runs hourly)
0 * * * * /usr/bin/systemd-resolve --flush-caches

# Windows Scheduled Task
schtasks /create /tn "Flush DNS" /tr "ipconfig /flushdns" /sc hourly
Verify Your DNS Records Now

Remember: Cache is Both Friend and Foe

While this guide shows how to clear DNS cache, remember:

  • Proper TTL settings prevent most cache issues
  • Test changes with dig/nslookup before blaming cache
  • When in doubt, check live DNS records first