DNS Records & Concepts

What is a DNS flush?

A DNS flush is the process of clearing the DNS cache stored locally on a device, the operating system’s record of recently resolved domain names and their corresponding IP addresses. Flushing the DNS cache forces the device to perform fresh DNS lookups for all subsequent requests rather than serving results from the locally cached copy of previous lookups.

Every operating system maintains a local DNS cache as a performance optimisation. When a browser resolves example.com the operating system stores the result, the IP address and the expiry time based on the record’s DNS TTL: in its local cache. Subsequent requests for example.com from any application on the device are served from this local cache without making any network DNS queries. This makes browsing faster by eliminating DNS lookup latency for recently visited domains.

The DNS flush empties this local cache entirely, discarding all stored records regardless of whether their TTL has expired. The next request for any domain triggers a fresh DNS lookup through the configured recursive resolver rather than using a cached result.

Why DNS flushing is needed

Under normal circumstances the DNS cache operates transparently and beneficially, stored records expire naturally according to their TTL and fresh lookups are performed when needed. DNS flushing becomes necessary in specific situations where the locally cached records are incorrect, outdated, or interfering with expected behaviour.

Testing DNS changes: the most common reason to flush DNS in a technical context. When a DNS record is changed, updating an A record to point to new infrastructure, adding a CNAME record to connect a domain to redirect management, verifying the change requires seeing the updated record rather than the cached old value. Without flushing the cache the device continues to use the old cached result even though the authoritative nameserver is serving the updated record. Flushing forces a fresh lookup that retrieves the current authoritative value.

Resolving website access problems: a domain that was previously accessible but has become unreachable may be caused by a stale cached DNS record. If the site has moved to a new IP address but the old IP address is still cached the browser attempts to connect to the old server which may be offline. Flushing the cache forces a fresh lookup that retrieves the current IP address.

Fixing incorrect DNS responses: DNS hijacking or cache poisoning at the resolver level may cause a device to receive and cache incorrect DNS responses. Flushing the local cache removes the poisoned entries, though the resolver cache may still be poisoned. Changing to a different resolver alongside the flush fully addresses resolver-level cache poisoning.

After changing DNS resolver settings: when a device’s configured DNS resolver is changed, switching from the ISP’s resolver to 1.1.1.1 or 8.8.8.8: flushing the local DNS cache ensures subsequent lookups use the new resolver rather than serving results that were cached when the old resolver was in use.

Clearing malware-related DNS modifications: some malware modifies DNS resolution by poisoning the local DNS cache with fraudulent entries, redirecting specific domains to malicious servers. Flushing the DNS cache removes these malicious entries. Removing the malware itself is also required to prevent re-poisoning.

Development and testing environments: developers testing websites and applications frequently make DNS changes and need to verify the current state of DNS resolution without waiting for cache expiry. DNS flushing allows immediate testing of updated DNS configurations.

How to flush DNS on different operating systems

The specific command for flushing DNS varies by operating system and version. The flush affects only the local OS-level DNS cache, not browser caches or resolver caches at the network level.

Windows

On all modern Windows versions the DNS cache is managed by the DNS Client service. Flushing is performed through the command prompt or PowerShell with administrator privileges:

ipconfig /flushdns
ipconfig /flushdns
ipconfig /flushdns

This command clears the DNS resolver cache and displays a confirmation message, “Successfully flushed the DNS Resolver Cache.” The command works on Windows XP through Windows 11 without modification.

To verify the cache was cleared:

ipconfig /displaydns
ipconfig /displaydns
ipconfig /displaydns

This command shows the current contents of the DNS cache, an empty or minimal output confirms the flush was successful.

macOS

The DNS flush command on macOS varies by version because Apple has changed the DNS caching daemon across major releases.

macOS Monterey, Ventura, Sonoma and later:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

This command flushes the DNS cache and restarts the mDNSResponder daemon which handles DNS resolution on macOS. Both parts of the command are needed, the first clears the cache and the second signals the daemon to reload.

macOS Big Sur and Catalina:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

The same command works for recent macOS versions.

macOS High Sierra, Mojave:

sudo killall -HUP mDNSResponder
sudo killall -HUP mDNSResponder
sudo killall -HUP mDNSResponder

macOS Sierra and El Capitan:

sudo killall -HUP mDNSResponder
sudo killall -HUP mDNSResponder
sudo killall -HUP mDNSResponder

The sudo prefix requires administrator password entry. A successful flush produces no output, silence confirms success on macOS.

Linux

Linux DNS cache flushing varies significantly by distribution and configuration because different Linux distributions use different DNS caching implementations.

Systems using systemd-resolved, most modern distributions including Ubuntu 18.04 and later, Fedora, and others:

sudo systemd-resolve --flush-caches
sudo systemd-resolve --flush-caches
sudo systemd-resolve --flush-caches

To verify the flush:

sudo systemd-resolve --statistics
sudo systemd-resolve --statistics
sudo systemd-resolve --statistics

The current cache size should be zero immediately after flushing.

Systems using nscd, Name Service Cache Daemon, common on older distributions:

sudo service nscd restart
sudo service nscd restart
sudo service nscd restart

or

sudo /etc/init.d/nscd restart
sudo /etc/init.d/nscd restart
sudo /etc/init.d/nscd restart

Systems using dnsmasq:

sudo service dnsmasq restart
sudo service dnsmasq restart
sudo service dnsmasq restart

Systems with no DNS cache, some Linux distributions do not cache DNS locally by default. On these systems there is nothing to flush, DNS lookups always go directly to the configured resolver. Ubuntu without systemd-resolved, for example, does not cache DNS at the OS level by default.

Android

Android does not provide a direct DNS flush command accessible to users without root access. The practical alternatives are:

Toggle airplane mode, on then off. This resets network connections including DNS state and effectively clears cached DNS entries.

Clear the browser cache, browser-level DNS caching is separate from OS-level caching. Clearing the browser cache removes browser-level DNS entries.

Forget and reconnect to the Wi-Fi network. Reconnecting resets the network connection and DNS state.

Restart the device. A full restart clears all DNS caches.

For rooted Android devices the DNS cache can be flushed through command-line tools but this is not practical for most users.

iOS and iPadOS

Like Android iOS does not expose a direct DNS flush command to users. The practical options are:

Toggle airplane mode on then off, the quickest method. Resets network state including DNS caches.

Restart the device, fully clears DNS caches.

Toggle Wi-Fi off and on, resets the network connection and associated DNS state.

Browser DNS cache vs OS DNS cache

DNS caching happens at multiple levels, the operating system cache and the browser’s own separate DNS cache. A DNS flush of the OS cache does not clear the browser DNS cache. Both may need to be cleared when troubleshooting DNS issues.

Chrome DNS cache: Chrome maintains its own internal DNS cache separate from the OS cache. To clear it navigate to:

chrome://net-internals/#dns
chrome://net-internals/#dns
chrome://net-internals/#dns

Click Clear host cache. This clears Chrome’s DNS cache without affecting other browsers or the OS cache.

Chrome also provides a socket pool that may hold open connections to old IP addresses. After clearing the DNS cache also clear sockets on the same page by clicking Flush socket pools.

Firefox DNS cache: Firefox caches DNS entries in memory. Clearing the cache through the browser settings clears DNS cache entries alongside other cached data. The keyboard shortcut Ctrl+Shift+Delete opens the clear history dialog where the cache can be cleared.

Firefox also has a hidden preference for DNS cache management at about:config: searching for network.dnsCacheEntries shows the configured cache size. Setting network.dnsCacheExpiration to 0 effectively disables DNS caching in Firefox, useful during development when frequent DNS changes are being made.

Safari: clearing the cache through Develop menu → Empty Caches clears Safari’s DNS cache. The Develop menu must be enabled in Safari preferences → Advanced → Show Develop menu in menu bar.

Edge: navigate to:

edge://net-internals/#dns
edge://net-internals/#dns
edge://net-internals/#dns

Click Clear host cache, identical to Chrome’s mechanism since Edge uses the same Chromium network stack.

DNS flush and redirect management

DNS flushing is directly relevant to redirect management in several practical scenarios.

Verifying redirect infrastructure connection: when connecting a domain to redirect management infrastructure by updating DNS records, adding a CNAME record pointing to the redirect service or updating A records: verifying the connection requires seeing the updated DNS record. Flushing the local DNS cache and browser DNS cache before testing ensures the test uses the fresh authoritative value rather than the cached pre-connection record.

Testing redirect rules after DNS changes: after updating DNS records to point to redirect infrastructure and configuring redirect rules flushing the DNS cache verifies the complete path, from DNS resolution to redirect rule application, is working correctly with the new configuration.

Diagnosing redirect failures: when a redirect is not working as expected one possibility is that the local DNS cache is serving an old record pointing to different infrastructure. Flushing the cache and testing again isolates whether the issue is DNS caching versus a configuration problem with the redirect rules themselves.

DNS propagation testing: when checking whether a DNS change has propagated flushing the local cache before each test ensures the test queries the configured resolver rather than returning locally cached results. Without flushing between tests the same cached result may be returned repeatedly even if the resolver has already updated.

Post-migration verification: after a domain migration that involves DNS changes flushing the local cache on test devices verifies that the new DNS configuration is working correctly from a clean state, simulating the experience of a first-time visitor who has no cached DNS entries.

What DNS flushing does not do

Understanding the limitations of DNS flushing prevents misunderstanding about what it accomplishes.

Does not clear resolver caches: flushing the local OS DNS cache does not affect the cache of the recursive resolver: the ISP’s resolver or a public resolver like 8.8.8.8: that the device uses for DNS lookups. After a local flush the device queries the resolver fresh, but if the resolver has a cached old record the device receives the old value again and caches it locally. To test what the resolver currently has cached without the local cache interfering use a tool like dig which bypasses the local cache entirely.

Does not speed up DNS propagation globally: flushing the local DNS cache on one device only affects that device. The DNS caches of resolvers worldwide are not affected. Other visitors continue to receive cached old records from their resolvers regardless of local cache flushing.

Does not fix resolver-level issues: if the resolver is returning incorrect values, due to DNS hijacking, cache poisoning, or configuration errors, flushing the local cache does not fix the problem. The device will query the resolver again after flushing and receive the same incorrect response which it will cache again locally. Changing to a different resolver addresses resolver-level issues.

Does not affect hosts file overrides: the local hosts file, which maps hostnames to IP addresses and overrides DNS entirely for listed entries, is not part of the DNS cache and is not cleared by a DNS flush. Hosts file entries persist until manually removed from the file.

Related terms

Related terms

Ready to keep every link alive?

Ready to keep every link alive?

Ready to keep every link alive?