Why You Need to Flush the DNS Cache
When you visit any website, your Windows operating system stores the domain name and corresponding IP address in a local temporary storage database known as the DNS Resolver Cache.
While this caching mechanism significantly speeds up subsequent page requests by skipping the external DNS lookup cycle, stale or poisoned records can cause serious headaches:
- Stale Server IP: If a web application moves to a new web server or hosting provider, Windows may continue attempting to reach the decommissioned IP until the Time-To-Live (TTL) counter expires.
- DNS Spoofing / Poisoning: Malicious programs or network MITM attacks may attempt to inject bogus records redirecting your web traffic to phishing replicas.
- ERR_NAME_NOT_RESOLVED: Frequent connection timeouts occur when old cache entries conflict with active DHCP network configurations.
Flushing the cache clears all cached IP records and forces your computer to request fresh, authoritative records directly from your configured DNS nameservers.
Method 1: Using Administrator Command Prompt (Standard Way)
This is the universal method that works across Windows 11, Windows 10, Windows 8, and Windows Server:
- Press
Win + Ron your keyboard to open the Run dialog. - Type
cmdand pressCtrl + Shift + Entertogether to launch Command Prompt directly in Administrator Mode. - In the command prompt window, type:
ipconfig /flushdns - Press
Enter. You will see the standard confirmation:Windows IP Configuration Successfully flushed the DNS Resolver Cache.
Method 2: Using PowerShell (Modern Administrator Way)
If you are using modern Windows PowerShell or PowerShell 7:
- Right-click the Windows Start menu button (or press
Win + X) and select Terminal (Admin) or PowerShell (Admin). - Run the native PowerShell cmdlet:
Clear-DnsClientCache - Unlike
ipconfig, PowerShell executes the command silently. To inspect your DNS cache before and after clearing, you can use:# View all active cached DNS records: Get-DnsClientCache # Clear the cache: Clear-DnsClientCache
How to Verify What is Currently in Your DNS Cache
Curious which domains Windows has cached in your local memory right now?
In Command Prompt, execute:
ipconfig /displaydns | more
This dumps every recorded domain name, record type (such as Type 1 for IPv4 A records or Type 28 for IPv6 AAAA records), and the remaining Time To Live (TTL) countdown in seconds. Press Spacebar to scroll through entries, or press Ctrl + C to exit.
Automating DNS Flush on System Startup (Optional)
If your development workflow regularly involves switching local hosts files or editing staging domains, you can create a one-click desktop shortcut:
- Right-click any empty space on your desktop and select New > Shortcut.
- In the target location box, enter:
cmd.exe /c ipconfig /flushdns - Click Next, name the shortcut
Flush DNS, and click Finish. - Right-click the new shortcut, go to Properties > Advanced, and check Run as administrator. Now you can double-click this shortcut anytime to refresh your network stack in 1 second.