Where Is the Hosts File in Windows? Location, Purpose, and What Affects How You Use It

If you've ever needed to block a website, redirect a domain, or troubleshoot a network issue on a Windows PC, someone has probably told you to "edit the hosts file." But where is it, exactly — and why does something so small matter so much?

What the Windows Hosts File Actually Is

The hosts file is a plain text file that your operating system reads before it consults a DNS server. When you type a web address into your browser, Windows first checks the hosts file to see if there's a local instruction for that domain. If there is, it follows that instruction. If not, it moves on to your DNS resolver.

This makes the hosts file a kind of manual override for domain-to-IP mapping. It predates the modern DNS system and has been part of Windows since its earliest versions.

The Exact Location of the Hosts File in Windows

On all modern versions of Windows — including Windows 10 and Windows 11 — the hosts file lives here:

C:WindowsSystem32driversetchosts 

That full path breaks down as:

  • C:WindowsSystem32 — the core system folder for 64-bit Windows components
  • driversetc — a subfolder modeled after the Unix /etc/ directory convention
  • hosts — the file itself, with no file extension

📂 You can navigate there directly in File Explorer, or paste the path into the Run dialog (Windows + R) to open the folder instantly.

The File Has No Extension

This trips people up constantly. The hosts file is not hosts.txt. It has no file extension at all. If you accidentally save it as hosts.txt, Windows will ignore it entirely. When opening or saving through a text editor, you need to set the file type filter to "All Files" to see and save it correctly.

How to Open and Edit the Hosts File

Because the hosts file sits inside a protected system directory, you need administrator privileges to edit it. Standard user accounts can view it but cannot save changes.

The most common approach:

  1. Search for Notepad in the Start menu
  2. Right-click it and select Run as administrator
  3. Use File → Open, navigate to C:WindowsSystem32driversetc
  4. Change the file type dropdown to All Files
  5. Select hosts and open it

Any changes you save will take effect almost immediately — no reboot required in most cases, though flushing the DNS cache with ipconfig /flushdns in Command Prompt ensures the changes are picked up right away.

What the Hosts File Can and Can't Do

Understanding the hosts file's actual scope helps set realistic expectations.

TaskHosts File Can Handle It?
Block a specific domain sitewide✅ Yes
Redirect a domain to a different IP✅ Yes
Block subdomains individually✅ Yes (each needs its own entry)
Block all subdomains with one rule❌ No wildcard support
Filter HTTPS traffic by content❌ No
Apply rules per user account❌ System-wide only
Override DNS for all apps on the PC✅ Generally yes

Each entry in the hosts file follows the format: IP address followed by a space, then the domain name. For example, pointing a domain to 0.0.0.0 or 127.0.0.1 is a common way to effectively block it.

Why the Same File Works Differently for Different Users 🔧

The hosts file itself is universal across Windows versions, but how useful it is to you depends heavily on your situation.

Technical skill level plays a major role. Editing a system file manually with no undo button is straightforward for someone comfortable with the command line, but carries real risk for users who might accidentally corrupt the file's formatting.

Your use case changes what you actually need. Someone using the hosts file to block ad domains on a single PC has very different needs from a developer using it to point local test domains to a development server. Both use the same file, but the stakes and complexity differ significantly.

Security software can interfere. Some antivirus programs monitor the hosts file for unauthorized changes — a legitimate protection against malware that hijacks it. If you make changes and they seem to revert, your security software may be treating your edits as a threat.

Browser behavior adds a variable. Some browsers, particularly those with their own built-in DNS resolution (like when DNS-over-HTTPS is enabled), may bypass the hosts file entirely. This means a domain you've blocked at the system level could still resolve correctly inside a specific browser.

Windows version and user account control (UAC) settings determine how much friction you'll encounter. On tightly managed systems — corporate machines, devices with restricted accounts, or systems where Group Policy has been applied — you may not have the access needed to edit the file even with administrator credentials.

The hosts file is one of the oldest and most reliable tools in Windows networking — simple, immediate, and available on every installation. Whether it's the right tool for what you're trying to accomplish depends on exactly what that is, and on how your specific machine is configured.