If you are experiencing "Site Cannot Be Reached" errors or find that a website you recently moved to a new server is still showing the old version, the most effective solution is often to flush your DNS cache. This process clears the local database of IP addresses stored by your operating system, forcing your computer to fetch updated information from the Domain Name System (DNS).

For those in a hurry, the primary command for Windows is ipconfig /flushdns, and for modern macOS, it is sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder.

Understanding the DNS Cache and Why You Need to Clear It

To understand why a simple command can fix complex connectivity issues, you first need to understand what the DNS cache is doing behind the scenes. Think of the Domain Name System as the phonebook of the internet. When you type a URL like example.com into your browser, your computer doesn't naturally know where that server is located. It needs an IP address, such as 192.0.2.1.

What is a DNS Cache?

A DNS cache, also known as a DNS resolver cache, is a temporary database maintained by a computer's operating system. It contains records of all the recent visits and attempted visits to websites and other internet domains. By keeping a local copy of these addresses, your system can load websites faster because it doesn't have to "ask" the global DNS servers for the same information every single time you click a link.

Why Do DNS Records Become Outdated?

Each DNS record has a specific lifespan known as TTL (Time-To-Live). This is a numerical value set by the website administrator that tells your computer how long it should keep the record in its cache before asking for a fresh one. However, several issues can occur:

  1. Server Migrations: If a website moves to a new hosting provider, its IP address changes. If your local TTL hasn't expired, your computer will keep trying to connect to the old, now-defunct IP address.
  2. DNS Poisoning (Spoofing): This is a security threat where attackers insert unauthorized DNS entries into your cache to redirect you to malicious websites.
  3. Network Configuration Changes: If you have recently changed your internet service provider (ISP) or modified your router settings, your old cache might conflict with the new network path.
  4. Technical Glitches: Sometimes, the cache simply becomes corrupted due to system crashes or software conflicts.

How to Flush DNS Command on Windows

Windows systems are the most common platforms where DNS flushing is required. The process is straightforward but requires administrative privileges to ensure the system-level cache is cleared.

Flushing DNS on Windows 11 and Windows 10

Windows 11 and 10 use the same core networking stack. You can use either the Command Prompt or Windows Terminal.

  1. Click the Start button and type cmd or Command Prompt.
  2. Right-click the result and select Run as Administrator. This is a crucial step; running it as a standard user may result in an "Access Denied" error.
  3. In the black console window, type the following command exactly: ipconfig /flushdns
  4. Press Enter.
  5. If successful, the system will return the message: "Successfully flushed the DNS Resolver Cache."

Using Windows PowerShell

If you prefer using PowerShell (the blue console), the command is identical.

  1. Right-click the Start button and select Windows Terminal (Admin) or PowerShell (Admin).
  2. Type ipconfig /flushdns and hit Enter.
  3. The output will be the same as the Command Prompt.

Flushing DNS on Windows 7, 8, and Older Versions

While these operating systems are less common today, many industrial and legacy systems still rely on them.

  • Windows 8/8.1: Press the Windows Key + X and select Command Prompt (Admin). Type ipconfig /flushdns and press Enter.
  • Windows 7 and Vista: Click the Start menu, go to All Programs > Accessories, right-click Command Prompt, and choose Run as Administrator. Execute the same ipconfig /flushdns command.

How to Flush DNS Command on macOS

Apple has changed the command used to clear the DNS cache several times throughout the history of macOS. Depending on which version you are running (Sonoma, Ventura, Monterey, etc.), the syntax might differ slightly.

For Modern macOS (Sonoma, Ventura, Monterey, Big Sur, and Catalina)

From macOS 10.15 onwards, the system uses a combination of two commands to ensure the cache is fully purged.

  1. Open Terminal. You can find this by pressing Command + Space and typing "Terminal," or by navigating to Applications > Utilities > Terminal.
  2. Copy and paste the following command: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  3. Press Enter.
  4. Because this command uses sudo (SuperUser Do), you will be prompted for your Mac’s login password. Note that the cursor will not move while you type the password—this is a standard security feature.
  5. Press Enter again. There is usually no "success" message on Mac; if the cursor returns to a new line without an error, it worked.

Commands for Legacy macOS Versions

If you are using an older Mac, the mDNSResponder service might not be the primary resolver, or the flags might be different.

  • macOS Sierra (10.12) to Mojave (10.14): sudo killall -HUP mDNSResponder
  • OS X Yosemite (10.10): sudo discoveryutil mdnsflushcache
  • OS X Lion, Mountain Lion, and Mavericks (10.7 – 10.9): sudo killall -HUP mDNSResponder
  • OS X Snow Leopard (10.6): sudo dscacheutil -flushcache

How to Flush DNS Command on Linux

Linux is unique because DNS caching is not always enabled by default at the OS level. Different distributions (Ubuntu, Fedora, CentOS, Arch) use different services to manage DNS. You first need to identify which service your system is using.

Using systemd-resolved (Most Common)

Most modern distributions like Ubuntu, Debian, and Fedora use systemd-resolved.

  1. Open your terminal.
  2. Enter the following command: sudo resolvectl flush-caches
  3. To verify that the caches were cleared, you can use: sudo resolvectl statistics Look for the "Current Cache Size" to see it drop to zero.

Using nscd (Name Service Cache Daemon)

Some older or enterprise-grade Linux setups use the nscd service.

  1. Open the terminal.
  2. Enter: sudo /etc/init.d/nscd restart Alternatively, you can use: sudo systemctl restart nscd

Using dnsmasq

If your Linux machine acts as a local DNS server or uses dnsmasq for managing its resolver, you need to restart the service to clear the cache.

  1. Type the following command: sudo systemctl restart dnsmasq

Beyond the OS: Flushing Browser-Level DNS Cache

Even after running the system-level commands above, you might still see old data. This is because modern web browsers like Google Chrome, Microsoft Edge, and Mozilla Firefox maintain their own internal DNS caches to shave off a few milliseconds of loading time.

Google Chrome and Microsoft Edge (Chromium-based)

Both Chrome and Edge share the same internal networking tools.

  1. Open a new tab in your browser.
  2. In the address bar, type: chrome://net-internals/#dns (for Edge, you can also use edge://net-internals/#dns).
  3. Look for the button labeled "Clear host cache" and click it.
  4. Next, go to the "Sockets" tab in the left-hand menu and click "Flush socket pools". This ensures that any active connections to the old IP addresses are severed.

Mozilla Firefox

Firefox handles DNS differently. Usually, a simple restart clears its cache, but you can force it manually.

  1. Type about:config in the address bar and press Enter. Click "Accept the Risk and Continue."
  2. Search for network.dnsCacheExpiration.
  3. Double-click the value and set it to 0. This effectively disables the cache.
  4. After troubleshooting, remember to change it back to the default (usually 60) to maintain performance.

Advanced Network Troubleshooting Commands

Flushing the DNS is often the first step, but sometimes the issue lies with your local IP address lease or the routing table. If ipconfig /flushdns doesn't work, try these additional commands.

The Release and Renew Sequence (Windows)

When you "release" your IP, you are telling the router that you are letting go of your current network address. "Renewing" asks the router for a fresh one.

  1. ipconfig /release: This disconnects you from the internet.
  2. ipconfig /renew: This establishes a new connection and often pulls fresh DNS settings from your router.

Changing Your DNS Provider

If your ISP's DNS servers are slow or corrupted (a common occurrence during regional outages), flushing your local cache won't help because the "source" information is bad. In our testing, switching to a public DNS provider like Google (8.8.8.8) or Cloudflare (1.1.1.1) significantly improves reliability.

  • On Windows: Go to Network Settings > Change Adapter Options > Right-click your connection > Properties > IPv4 > Use the following DNS server addresses.
  • On Mac: System Settings > Network > Advanced > DNS tab.

What to Expect After Running the Command

When you execute a DNS flush, you are essentially deleting the "shortcut" list your computer uses to find websites.

  • Initial Delay: The very first time you visit a website after a flush, it might take an extra half-second to load. This is because your computer has to perform a full recursive lookup to find the IP address.
  • Fresh Content: If a website has updated its design or moved servers, you should now see the latest version.
  • Error Resolution: Common errors like DNS_PROBE_FINISHED_NXDOMAIN or ERR_NAME_NOT_RESOLVED often disappear immediately.

Common Error Messages and Troubleshooting

"The requested operation requires elevation"

This occurs on Windows if you do not run the Command Prompt as an administrator. To fix it, close the window, right-click the Command Prompt icon, and select Run as Administrator.

"Command not found" or "is not recognized"

On Windows, ensure you are typing ipconfig correctly (not ifconfig, which is for Linux/Mac). On Linux, if resolvectl is not found, try systemd-resolve. If neither works, your system might not have a local DNS cache enabled, meaning your issue lies elsewhere (like the router or the ISP).

"Could not flush the DNS Resolver Cache: Function failed during execution"

This is a rare error usually caused by the "DNS Client" service being disabled in Windows. You can fix this by:

  1. Pressing Win + R, typing services.msc, and hitting Enter.
  2. Locating DNS Client.
  3. Ensuring it is set to Automatic and is currently Running.

Summary Table of Commands

Operating System Primary Command
Windows (All) ipconfig /flushdns
macOS (Modern) sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Linux (Ubuntu/Fedora) sudo resolvectl flush-caches
Linux (nscd) sudo systemctl restart nscd
Chrome / Edge chrome://net-internals/#dns -> Clear host cache

FAQ: Frequently Asked Questions about Flushing DNS

What is pdf converter? (Wait, is this relevant?)

Actually, this is a common search distraction. A PDF converter is a tool to change file formats, which has nothing to do with DNS. Focus on networking tools for internet issues.

How to convert jpg to pdf?

Similarly, this is unrelated to DNS. If you are struggling with internet connectivity, ignore file conversion and focus on flushing your cache or resetting your router.

Is it safe to flush my DNS?

Yes, it is 100% safe. You are only deleting temporary text files that map domain names to IP addresses. Your computer will automatically rebuild these files the next time you browse the web. No personal files or browser history will be deleted.

How often should I flush my DNS?

There is no need to do it on a regular schedule. You should only flush your DNS when you are having specific connection problems, seeing outdated website content, or after changing your network settings.

Does flushing DNS speed up my internet?

It won't increase your raw download or upload speed (which is determined by your ISP). However, it can make your browsing feel "snappier" by fixing DNS-related delays or resolving errors that make pages fail to load.

Can I flush DNS on a smartphone?

On Android and iOS, there isn't a direct terminal command like on a PC. However, toggling Airplane Mode on and off for 30 seconds usually resets the network stack and clears the DNS cache. On Android, you can also go to Chrome and use the chrome://net-internals/#dns method mentioned above.

What happens if I don't flush my DNS?

Eventually, the TTL for each record will expire, and your computer will refresh the cache on its own. Flushing the DNS simply forces this process to happen immediately rather than waiting for hours or days.

Conclusion

The flush dns command is one of the most powerful yet simple tools in a user's troubleshooting arsenal. Whether you are a web developer testing a new site migration or a home user trying to fix a stubborn "Server Not Found" error, knowing the right syntax for your operating system is essential. By clearing your local resolver cache on Windows, macOS, or Linux, you ensure that your device is looking at the most current version of the internet, free from outdated or malicious records. If flushing the DNS doesn't solve your problem, the next steps should include restarting your router and checking for ISP-wide outages.