User Agents

Web browsers and everyday web tech, explained

Clear Cache CMD: How to Flush DNS and Temp Files

· 4 min read · Cookies and Cache

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Clearing your cache via the Command Prompt (CMD) allows you to remove temporary data that may be slowing down your system, causing network connectivity issues, or preventing updated website content from loading. By using specific commands, you can flush the DNS resolver cache to fix "Page Not Found" errors and clear system-level temporary files that take up valuable disk space. This process is often faster than navigating through multiple GUI menus and is essential for troubleshooting network configurations.

What You'll Need

  • A computer running Windows (10, 11, or older versions).
  • Administrative privileges on the user account to execute system-level commands.
  • Basic knowledge of how to type and enter commands into a terminal window.

Step-by-Step

Part 1: Flushing the DNS Cache

The DNS (Domain Name System) cache stores the IP addresses of websites you have visited. If a website changes its IP address but your computer still has the old one cached, you will encounter connection errors. Flushing this cache forces Windows to request the most current address.

  1. Click the Start button or press the Windows key on your keyboard.
  2. Type cmd into the search bar.
  3. Right-click on Command Prompt in the search results and select Run as administrator. This is crucial; without admin rights, the command will be denied.
  4. In the black window, type the following command exactly: ipconfig /flushdns
  5. Press Enter.
  6. You should see a confirmation message stating: "Successfully flushed the DNS Resolver Cache."

Part 2: Clearing Temporary System Files

While there isn't a single "clear all cache" command, you can use CMD to wipe the temporary folders where Windows and applications store cached data.

  1. Open the Command Prompt as administrator as described in the previous section.
  2. To clear the user-level temporary files, type the following command: del /q /f /s %temp%\*
  3. Press Enter. The /q flag ensures "quiet" mode (no confirmation prompts), /f forces the deletion of read-only files, and /s deletes files from all subdirectories.
  4. To clear the system-level temporary files, type: del /q /f /s C:\Windows\Temp\*
  5. Press Enter.

Part 3: Resetting the Winsock Catalog

If you are clearing cache to fix deep-seated network issues, resetting the Winsock catalog (which handles input/output requests for network software) is a recommended final step.

  1. In the administrator Command Prompt, type: netsh winsock reset
  2. Press Enter.
  3. You will be prompted to restart your computer to complete the reset. Type shutdown /r /t 0 to restart immediately or restart manually via the Start menu.

Common Mistakes

  • Forgetting Administrator Mode: The most common error is opening CMD as a standard user. Commands like netsh and system-level del commands will return an "Access Denied" message if not run as an administrator.
  • Typing Errors: CMD is literal. A missing space before a forward slash (e.g., typing ipconfig/flushdns instead of ipconfig /flushdns) will result in an "is not recognized as an internal or external command" error.
  • Deleting Critical Files: While the %temp% folder is generally safe, users should avoid using the del command in directories they are unfamiliar with, as there is no "Recycle Bin" for files deleted via CMD.

Tips

  • Use Tab Completion: If you are typing a long file path, you can press the Tab key to automatically complete the folder or file name, reducing the chance of typos.
  • Combine Commands: You can run multiple commands in one line by using the & symbol. For example: ipconfig /flushdns & ipconfig /release & ipconfig /renew.
  • Create a Batch File: If you frequently clear your cache, open Notepad, paste the commands you use, and save the file with a .bat extension. You can then run all these steps by simply double-clicking that file as an administrator.

Troubleshooting

If you encounter issues while following these steps, consider the following solutions:

  • "Access Denied" Error: Double-check that the top of your Command Prompt window says "Administrator: Command Prompt." If it only says "Command Prompt," close it and right-click to run as administrator.
  • "File in Use" Messages: When clearing temp files, you will likely see messages saying some files cannot be deleted because they are in use. This is normal; it means a program currently open is using that cache file. You can ignore these messages or close all open applications and try again.
  • Command Not Recognized: Ensure there is a space between the main command (e.g., ipconfig) and the switch (e.g., /flushdns). Check for spelling mistakes.

Frequently Asked Questions

Does clearing the DNS cache delete my browser history?

No. Flushing the DNS cache only removes the mapping of domain names to IP addresses. Your browser history, cookies, and saved passwords remain untouched.

Is it safe to run these commands daily?

Yes, it is safe. However, it is generally unnecessary to do so daily. Clearing cache frequently may slightly slow down the initial loading of websites because the computer must fetch the DNS information from the server again.

Will this fix my slow internet speed?

It may fix connectivity issues or "site cannot be reached" errors, but it will not increase your actual bandwidth or ISP-provided internet speed.

What is the difference between flushing DNS and resetting Winsock?

Flushing DNS clears the address book of websites. Resetting Winsock resets the actual software interface that allows your computer to communicate with the network hardware.

Can I use these commands in PowerShell?

Yes, most of these commands work in PowerShell, provided you launch PowerShell as an administrator. The ipconfig and netsh commands are compatible with both environments.