TechBuzzPro

Host File Location in Windows: Find & Edit It

· 4 min read · Windows & PC

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

The host file in Windows is a plain text file that maps domain names to IP addresses, allowing you to override DNS settings locally. Editing it lets you block websites, redirect domains for testing, or troubleshoot network issues. You can find and edit the host file using built-in tools, but you'll need administrator privileges. This guide shows you exactly where the host file is located, how to access and edit it safely, and what to watch out for.

What You'll Need

  • Administrator access to your Windows PC
  • Notepad or another plain text editor (not Word or WordPad)
  • Basic understanding of IP addresses and domain names

Step-by-Step

  1. Open File Explorer by clicking the folder icon on the taskbar or pressing Windows + E.
  2. Navigate to the system drive, usually C:\. This is where Windows is installed.
  3. Open the Windows folder. This is located at the root of the C: drive.
  4. Inside the Windows folder, open the System32 folder.
  5. Go into the drivers folder.
  6. Open the etc folder. This folder contains system configuration files, including the host file.
  7. Look for a file named hosts (no file extension). This is the host file.
  8. Right-click the hosts file and select Open with > Notepad. Do not double-click it—this may open it in the wrong program or without proper permissions.
  9. If prompted by User Account Control (UAC), click Yes to allow the app to make changes.
  10. Once open, you can view and edit the contents. Each line should follow the format: IP_address domain_name. For example: 127.0.0.1 example.com blocks access to example.com by redirecting it to your local machine.
  11. After making changes, click File > Save to save your edits.
  12. Close Notepad. The changes take effect immediately—no restart is required.

Common Mistakes

  • Editing without administrator rights: If you don’t run Notepad as an administrator, you won’t be able to save changes. Always allow UAC prompts when opening the file.
  • Using the wrong editor: Word processors like Microsoft Word add formatting that corrupts the file. Always use Notepad or a plain text editor.
  • Incorrect syntax: Each entry must be IP_address followed by a space or tab, then the domain_name. Avoid commas, quotes, or extra spaces.
  • Forgetting to save: Some users close Notepad without saving. Always confirm the file was saved by reopening it.
  • Typing errors in domains or IPs: A single typo can cause a site to fail to load or redirect incorrectly.

Tips

  • Backup the original file: Before editing, copy the hosts file and rename it to hosts.bak. If something goes wrong, you can restore it.
  • Use comments: Add lines starting with # to explain your entries. For example: # Block tracking site above a blocked domain.
  • Flush DNS after changes: Open Command Prompt as administrator and run ipconfig /flushdns to clear old DNS entries and ensure your changes take effect immediately.
  • Test one entry at a time: When adding multiple entries, test each one before adding more to isolate issues.
  • Use 127.0.0.1 to block sites: Redirecting unwanted domains to this loopback address prevents them from loading.

Troubleshooting

If your changes don’t work or cause issues, follow these steps:

  1. Check file permissions: Right-click the hosts file, select Properties, and ensure your user account has full control under the Security tab.
  2. Verify administrator mode: If you can’t save, reopen Notepad as an administrator: search for Notepad in the Start menu, right-click it, and choose Run as administrator, then open the file manually.
  3. Confirm file location: The correct path is C:\Windows\System32\drivers\etc\hosts. Double-check each folder.
  4. Check for hidden extensions: Ensure the file isn’t actually named hosts.txt. In Folder Options, disable “Hide extensions for known file types” to verify.
  5. Restore from backup: If the system behaves oddly, delete the edited file and rename hosts.bak back to hosts.
  6. Flush DNS cache: Run ipconfig /flushdns in an elevated Command Prompt to clear outdated records.
  7. Scan for malware: Some malware modifies the hosts file. Run a full system scan using Windows Security or a trusted antivirus.

Frequently Asked Questions

Can I edit the hosts file on any Windows version?

Yes, the hosts file exists in all modern Windows versions including Windows 10 and 11, and is located in the same path.

Do I need to restart after editing the hosts file?

No, changes take effect immediately. However, flushing the DNS cache ensures faster recognition.

Why can’t I save changes to the hosts file?

This usually happens without administrator rights. Always open Notepad as an administrator when editing system files.

Can I block multiple domains with one IP?

Yes. List each domain on a separate line pointing to the same IP, such as 127.0.0.1, to block multiple sites.

Is editing the hosts file safe?

Yes, if done correctly. Mistakes can block websites or disrupt network functions, but the file can always be restored.

Can malware change the hosts file?

Yes. Malware sometimes redirects legitimate sites to malicious IPs. Regular checks and antivirus scans help prevent this.