OtherLow

Clearing DNS Cache: Instructions for Windows, macOS, and Linux

This guide explains how to clear the DNS cache on Windows, macOS, and Linux to resolve website access issues and improve network performance.

Updated at February 17, 2026
5-10 min
Easy
FixPedia Team
Применимо к:Windows 10, Windows 11macOS Monterey, Ventura, SonomaUbuntu 20.04, 22.04, Debian 11, Fedora 36 and above

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:

  1. You have administrator privileges (or sudo access) on your computer.
  2. An internet connection is established (to verify the result).
  3. 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 mDNSResponder separately.

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.com or dig example.com (if dig is 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).

F.A.Q.

Do I need to restart my computer after clearing the DNS cache?
Why is the site still not opening after clearing the cache?
How often should I clear the DNS cache?
Will clearing the DNS cache delete my data or settings?

Hints

Identify your operating system
Open the terminal/command prompt with administrator privileges
Enter the command corresponding to your OS
Ensure the command executed successfully
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community