Introduction
A DNS cache (domain name cache) is a temporary storage on your computer where the results of domain name resolution to IP addresses are saved. Over time, these records can become outdated, especially if a website's IP address changes. This leads to errors like "DNS_PROBE_FINISHED_NXDOMAIN" or when a site doesn't update as it should. Flushing the DNS cache forces the system to request fresh data from DNS servers, which often resolves website access issues and improves network performance.
In this guide, you'll learn how to quickly clear the DNS cache on Windows, macOS, and Linux. The process takes less than a minute and doesn't require installing additional software.
Requirements / Preparation
Before you begin, ensure that:
- You have administrator privileges (or sudo access) on your computer.
- An internet connection is established (to verify the result).
- You know which operating system you are using.
Flushing the DNS Cache in Windows
Step 1: Open Command Prompt or PowerShell as Administrator
Press Win + X and select "Command Prompt (Admin)" or "Windows PowerShell (Admin)". If prompted by UAC, click "Yes".
Step 2: Execute the cache flush command
Type the command and press Enter:
ipconfig /flushdns
If the command succeeds, you will see the message:
Successfully flushed the DNS resolver cache.
Flushing the DNS Cache in macOS
Step 1: Open Terminal
Find Terminal via Spotlight (Cmd + Space) or in the Utilities folder.
Step 2: Execute the cache flush command
Type the following command (requires administrator password):
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Enter your password (characters are not displayed) and press Enter. There should be no errors.
💡 Tip: On older versions of macOS (pre-Mavericks), use
sudo killall -HUP mDNSResponderseparately.
Flushing the DNS Cache in Linux
In Linux, DNS caching can be handled by different services. The most common are systemd-resolved and nscd.
Step 1: Identify which DNS service is in use
Run in the terminal:
ps aux | grep -E "(systemd-resolve|dnsmasq|nscd)"
If you see a systemd-resolved process, use the method for systemd-resolved. If nscd is present, use the method for nscd. If nothing is found, caching might be disabled or another daemon (like unbound) is used.
Step 2: Execute the appropriate command
For systemd-resolved (relevant for Ubuntu 22.04+, Debian 11+, Fedora 36+):
sudo systemd-resolve --flush-caches
Or on some distributions:
sudo systemd-resolved-flush-caches
For nscd (used in some older distributions):
sudo nscd -i hosts
If dnsmasq is used (common in routers or local networks):
sudo killall -HUP dnsmasq
Verifying the Result
After flushing the cache, try opening a website that previously failed to load. You can also check name resolution:
- Windows/macOS/Linux:
nslookup example.comordig example.com(ifdigis installed). Ensure the returned IP address is current.
If the problem persists, the issue might lie elsewhere in your network settings (firewall, proxy, DNS servers). In that case, refer to related guides, such as resetting network adapters in Windows or changing DNS servers.
Potential Issues
Access Error (Permission denied)
- Cause: The command was run without administrator privileges.
- Solution: Run the terminal/command prompt as administrator or use
sudo.
Command Not Found
- Cause: The DNS service is not installed or in use (e.g., in minimal Linux installations).
- Solution: Install the appropriate service (e.g.,
sudo apt install systemd-resolved) or configure a DNS client without caching.
Failed to flush cache: No such file or directory Error (Linux)
- Cause: The systemd-resolved service is not active.
- Solution: Enable the service:
sudo systemctl enable --now systemd-resolved.
Flushing Did Not Help
- Cause: The problem is not with the DNS cache but with network settings, firewall, or the website itself.
- Solution: Check connectivity (
ping 8.8.8.8), temporarily disable the firewall, or switch to public DNS servers (e.g., 8.8.8.8).