Flush DNS Cache: Why, When, and How to Do It on Any Device

The Domain Name System (DNS) is often called the “phonebook of the internet.” It translates human-readable domain names like example.com into machine-readable IP addresses (e.g., 192.0.2.1). To speed up this translation process, operating systems and browsers store recent results in a DNS cache. While caching improves performance, it can become stale, corrupted, or exploited, leading to connectivity errors, security risks, and privacy leaks. Flushing (clearing) this cache is a fundamental troubleshooting step. This guide details why flushing is critical, when to perform it, and exact step-by-step methods for Windows, macOS, Linux, ChromeOS, mobile devices (iOS and Android), and major web browsers.

Why Flush DNS Cache? The Underlying Mechanics

Every time you visit a website, your device queries a DNS resolver. The response—the IP address—is stored locally for a specific Time to Live (TTL) set by the domain owner. Caching reduces network traffic and speeds up repeat visits. However, problems arise from three primary mechanisms:

1. Stale Records: A website changes its IP address (e.g., migrating to a new server). Your device still holds the old, incorrect IP. Attempting to load the site results in “DNS_PROBE_FINISHED_NXDOMAIN,” “Server Not Found,” or a connection to the wrong server. Flushing removes these obsolete entries.

2. Cache Poisoning (DNS Spoofing): Malicious actors can inject false DNS records into your cache, redirecting you to phishing or malware sites. A flush discards these forged entries, restoring legitimate resolution. While modern DNSSEC mitigates this, cache corruption from router or local network issues still occurs.

3. Privacy and IP Leakage: Your DNS cache contains a history of every domain you’ve visited. Anyone with access to your device (e.g., after a security breach or shared computer use) can reconstruct your browsing history. Flushing clears this forensic trail.

4. Configuration Changes: After altering your DNS server address (e.g., switching from your ISP’s DNS to Cloudflare 1.1.1.1 or Google 8.8.8.8), the old cache persists. Queries will still be sent to the old server until the cache expires or is flushed.

When to Flush: Diagnostic Scenarios

Flushing is not a routine maintenance task. Perform it only in these specific situations:

  • After changing DNS servers: Immediately after updating your network settings to use a third-party DNS provider.
  • Loading errors on specific sites: You can access the internet generally, but a particular website consistently fails to load, shows a “404” incorrectly, or displays an outdated version.
  • After website migration: If you run a website and moved to a new host, flush your local cache and encourage users to do the same.
  • During security incident response: After removing malware or identifying a DNS hijacking attempt.
  • When testing DNS propagation: Developers and system administrators flush to ensure they see the latest DNS records without waiting for TTL expiry.
  • Network configuration changes: After switching networks (e.g., from home to public Wi-Fi) or adjusting router settings.
  • Persistent “DNS lookup failed” errors: Before escalating to ISP support.
  • Before sensitive browsing: On a shared or public device, flush to erase browsing residue.

Note: Flushing does not delete browser history, cookies, or cached web pages (HTML, images). It only removes DNS IP mappings.

How to Flush DNS on Every Major Device

1. Windows (All Versions: 10, 11, 8, 7)

Windows uses the ipconfig /flushdns command. The cache stores results from all network adapters and DNS Client service queries.

Method: Command Prompt (Admin)

  • Press Windows Key + X and select Terminal (Admin) or Command Prompt (Admin).
  • Type: ipconfig /flushdns and press Enter.
  • Expected output: “Successfully flushed the DNS Resolver Cache.”

Method: PowerShell (Admin)

  • Right-click the Start button and select Windows PowerShell (Admin).
  • Type: Clear-DnsClientCache and press Enter.

Verification:

  • ipconfig /displaydns shows all cached entries. After flushing, only localhost entries remain.

Windows Service Note: If the DNS Client service is disabled, flush command does nothing. To check: services.msc → DNS Client → ensure “Running” and “Automatic.”

2. macOS (Ventura, Sonoma, Sequoia, and Earlier)

macOS uses mDNSResponder for DNS resolution. The command varies by macOS version but all modern versions use the same syntax.

Method: Terminal

  • Open FinderApplicationsUtilitiesTerminal.
  • Type the command based on your OS:
macOS Version Command
macOS 10.12 (Sierra) and later sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
macOS 10.10–10.11 sudo discoveryutil mdnsflushcache
macOS 10.7–10.9 sudo killall -HUP mDNSResponder
  • Enter your administrator password when prompted (no visual feedback while typing).
  • No success message is displayed on modern macOS versions. The cache is cleared silently.

Verification:

  • dscacheutil -cachedump -entries | grep -c "Key" will show zero or near-zero entries.

3. Linux (Ubuntu, Debian, Fedora, Arch)

Linux distributions vary in DNS caching services. Three common systems exist:

A. systemd-resolved (Ubuntu ≥16.04, Fedora, Arch)

  • Command: sudo resolvectl flush-caches
  • Alternative: sudo systemd-resolve --flush-caches

B. dnsmasq (common on network managers)

  • Restart the service: sudo systemctl restart dnsmasq
  • Or if running locally: sudo killall -HUP dnsmasq

C. NSCD (Name Service Cache Daemon)

  • Restart: sudo systemctl restart nscd
  • Or flush: sudo nscd -i hosts

No Cache Installed? Many minimal Linux installations do not cache DNS by default. Flushing is unnecessary.

4. ChromeOS (Chromebooks)

ChromeOS integrates caching into the operating system and the Chrome browser.

Method: Crosh Shell

  • Press Ctrl + Alt + T to open Crosh.
  • Type: shell and press Enter.
  • Type: sudo sh -c "echo 0 > /proc/sys/net/ipv4/tcp_congestion_control; sync; echo 3 > /proc/sys/vm/drop_caches" (This clears system caches including DNS).
  • Alternatively, restart the shill (connection manager): sudo restart shill

Simpler Method: Restart the Chromebook — A full reboot clears the DNS cache.

5. iOS (iPhone, iPad)

iOS manages DNS caching internally and does not expose a direct flush command to users. The most reliable method is:

Method 1: Toggle Airplane Mode

  • Swipe into Control Center.
  • Tap the Airplane Mode icon to enable it.
  • Wait 15 seconds, then tap again to disable it.
  • This forces the device to re-establish all network connections, clearing temporary DNS data.

Method 2: Restart the Device

  • Press and hold the power button (and volume button on models with Face ID) until “slide to power off” appears.
  • Wait 30 seconds, then turn it back on.

Method 3: Reset Network Settings (Last resort)

  • SettingsGeneralTransfer or Reset iPhoneResetReset Network Settings.
  • This erases all saved Wi-Fi passwords, VPNs, and Bluetooth pairings. Use only if DNS issues persist.

6. Android (Stock, Samsung, Pixel)

Android does not provide a built-in DNS flush command. Solutions depend on the manufacturer and Android version.

Method 1: Toggle Network Connection

  • Open SettingsConnectionsWi-Fi.
  • Tap the gear icon next to your connected network.
  • Select Forget. Then reconnect to the network.

Method 2: Restart the Device

  • Press and hold the power button, select Restart or power off and on.

Method 3: Change DNS Server (Forces Cache Refresh)

  • SettingsConnectionsWi-Fi → Tap gear icon → IP settings → Change to Static.
  • Set DNS 1 to 1.1.1.1 and DNS 2 to 1.0.0.1 (or 8.8.8.8/8.8.4.4).
  • Save the settings, then switch back to DHCP if desired.

Method 4: Developer Options (Root not required)

  • SettingsAbout phone → Tap “Build number” seven times to enable Developer options.
  • SettingsSystemDeveloper optionsNetworkingEnable “Wi-Fi verbose logging” or Reset Wi-Fi, mobile & Bluetooth (varies by device).

7. Web Browsers (Chrome, Firefox, Edge, Safari)

Browsers maintain their own internal DNS caches separate from the OS.

Google Chrome / Microsoft Edge / Brave / Vivaldi

  • Type in the address bar: chrome://net-internals/#dns
  • Click the Clear host cache button.
  • Alternatively, in Chrome: chrome://net-internals/#socketsFlush socket pools.

Mozilla Firefox

  • Type in the address bar: about:networking#dns
  • Click Clear DNS Cache.
  • Alternatively: SettingsPrivacy & SecurityNetwork SettingsSettingsEnable “DNS over HTTPS” — toggling this forces a flush.

Safari (macOS)

  • Safari does not maintain a separate DNS cache; it uses the system cache. Flushing the macOS DNS cache (as described above) clears Safari’s resolution data.

Troubleshooting Flush Failures

  • “Access denied” in Windows: Run Command Prompt as Administrator.
  • “No such command” in Linux: Install the appropriate package (e.g., sudo apt install systemd-resolved for Ubuntu).
  • Flush appears successful but problem persists:
    1. Clear browser cache (Ctrl+Shift+Del).
    2. Reset router (unplug for 30 seconds).
    3. Check for manual proxy settings (SettingsNetwork & InternetProxy → Ensure “Automatically detect settings” is on).
    4. Use nslookup google.com to verify your current DNS server.
  • After flush, sites load slowly: Temporary re-caching is normal; performance returns within minutes.

Security and Privacy Considerations

Flushing the DNS cache is safe and non-destructive. It does not:

  • Delete browser passwords.
  • Remove saved bookmarks or history.
  • Affect network credentials or VPN configurations.
  • Harm system files.

However, frequent flushing negates the performance benefit of caching. Reserve it for troubleshooting. If you are concerned about privacy on a shared device, consider using a private browsing mode (e.g., Incognito) or a DNS-over-HTTPS (DoH) service that encrypts queries.

Automated Flushing via Script

Power users can create scripts to flush on schedule or after specific events:

Windows Batch Script:

@echo off
ipconfig /flushdns
echo DNS Cache Flushed.

macOS Shell Script:

#!/bin/bash
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

Linux Cron Job (daily at 3 AM):

0 3 * * * /usr/bin/resolvectl flush-caches

Flushing DNS cache is a precise, low-risk intervention that resolves a wide range of connectivity and security issues. By understanding the underlying reasons and following device-specific instructions, you maintain efficient and secure internet access.

Leave a Comment