How To

Flush DNS Cache on Windows, Linux, and macOS: Quick Commands

DNS cache is a temporary database your OS and browser build as you browse. Each time you visit a website, the domain-to-IP mapping is saved locally, cutting out the round trip to a remote DNS server on repeat visits.

Stale entries are the most common reason to flush the DNS cache: a server moves to a new IP, but your OS or browser still routes to the old address. This guide covers how to clear the DNS cache on Windows, Linux, and macOS, and how to flush the separate cache stored inside Chrome and Firefox.

Flush DNS Cache on Windows

The command is the same on Windows 10, Windows 11, and earlier supported releases.

Open Command Prompt with administrator privileges. Type cmd in the Windows search bar, right-click Command Prompt, and select Run as administrator.

Run the flush command:

bashipconfig /flushdns

A successful run prints:

Windows IP ConfigurationSuccessfully flushed the DNS Resolver Cache.

ipconfig /flushdns clears all entries from the Windows DNS Resolver Cache. The OS makes fresh DNS queries on the next domain lookup.

Clear the DNS Cache on Linux

Linux does not cache DNS entries at the OS level by default. DNS caching only happens when a dedicated service is installed and running. Before flushing, check which caching service is active on your system.

systemd-resolved – the default resolver on Ubuntu, Fedora, and most modern desktop distributions. Check whether it is running:

bashsudo systemctl is-active systemd-resolved

If the output is active, flush the cache with:

bashsudo resolvectl flush-caches

The command produces no output on success. Older guides show sudo systemd-resolve --flush-caches – that command is deprecated on modern systems and replaced by resolvectl.

DNSMasq – a lightweight caching nameserver common on embedded and router-style Linux systems. Restart the service to clear its cache:

bashsudo systemctl restart dnsmasq.service

Nscd – the Name Service Cache Daemon, found on older Red Hat and CentOS systems:

bashsudo systemctl restart nscd.service

Clear DNS Cache on macOS and in Web Browsers

macOS. All current macOS releases use mDNSResponder as the DNS caching daemon. Clear its cache with:

bashsudo killall -HUP mDNSResponder

The -HUP flag sends a SIGHUP signal to mDNSResponder, which tells the process to flush its cache and reload its configuration without stopping. The command succeeds silently.

Google Chrome. Chrome maintains its own DNS cache separately from the OS. Flushing the OS cache alone will not clear it. Open a new tab and go to:

chrome://net-internals/#dns

Click Clear host cache. The page shows every domain Chrome has cached along with resolution timestamps, so you can also confirm whether a specific domain is resolving correctly.

Firefox. Firefox caches DNS entries for 60 seconds by default, controlled by the network.dnsCacheExpiration preference. To flush it immediately, open a new tab and navigate to:

about:config

Search for network.dnsCacheExpiration and temporarily set the value to 0, then click OK. Firefox discards all cached entries. Set the value back to 60 to restore the default. A full browser restart also clears Firefox’s DNS cache without touching any settings.

Flush the OS DNS cache first, then the browser cache if you are still landing on the wrong site. Browsers hold their own DNS records independently of the system, which is why flushing just one sometimes does not fix the problem. Leave a comment below if you run into any issues.

Cyber Defence

Recent Posts

rmmod Command in Linux: Remove Kernel Modules and Blacklisting

The rmmod command in Linux removes a loaded module from the running kernel. Because the kernel has…

14 seconds ago

free Command in Linux: Check Memory Usage and Interpret Output

The free command in Linux gives you a quick summary of RAM and swap usage. It reads…

5 minutes ago

diff Command in Linux: Compare Files and Create Patches

The diff command in Linux compares two text files line by line and shows the lines that…

10 minutes ago

Change User Password in Ubuntu: Command Line and GNOME GUI

Using a strong, unique password for every account is one of the most effective security…

1 day ago

Enable and Disable the Root Account in Ubuntu: Full Guide

Ubuntu locks the root account by default. New users often wonder what the root password…

1 day ago

Configure Netplan on Ubuntu: DHCP, Static IP, Wi-Fi, and Bridges

Since Ubuntu 17.10, networking is configured with Netplan rather than the older /etc/network/interfaces file. You write a…

1 day ago