Where to Find the Hosts File in Windows (And What It Does)
The hosts file is one of Windows' oldest networking tools — a plain text file that maps hostnames to IP addresses before your system even consults a DNS server. Knowing where it lives, how it works, and what affects how you use it can save you real troubleshooting time.
What Is the Hosts File?
Every time you type a web address into a browser, your computer needs to translate that human-readable name (like example.com) into a numeric IP address. Normally, that job goes to a DNS (Domain Name System) server — usually provided by your ISP or a service like Google or Cloudflare.
The hosts file steps in before DNS. If Windows finds a matching entry in the hosts file, it uses that IP address immediately — no DNS query needed. This makes it useful for:
- Blocking websites by redirecting them to a non-existent address
- Testing a website on a new server before DNS propagates
- Overriding DNS for specific local network devices
- Parental filtering and ad blocking (in basic setups)
Where Is the Hosts File Located in Windows?
Regardless of whether you're running Windows 10, Windows 11, or older versions like Windows 7 or 8, the hosts file is always in the same place:
C:WindowsSystem32driversetchosts There is no file extension — the file is simply named hosts, not hosts.txt. This trips up a lot of users who expect a familiar extension.
How to Navigate There
You can reach the file several ways:
- File Explorer: Paste
C:WindowsSystem32driversetcdirectly into the address bar and press Enter. You'll see a handful of files includinghosts. - Run dialog: Press
Win + R, typenotepad C:WindowsSystem32driversetchosts, and press Enter (you may need to run Notepad as administrator). - Command Prompt or PowerShell: Navigate using
cd C:WindowsSystem32driversetcand then open with your editor of choice.
Why You Can't Just Double-Click and Edit It 🔒
This is where many users hit a wall. The hosts file is protected by Windows permissions. Standard user accounts can read the file but not save changes to it.
To edit the hosts file, you need to open your text editor as an administrator:
- Search for Notepad in the Start menu
- Right-click it and select Run as administrator
- Go to File > Open, navigate to
C:WindowsSystem32driversetc - Change the file filter from "Text Documents" to All Files — otherwise the hosts file won't appear
- Open and edit as needed, then save
Skipping the administrator step is the most common reason edits don't stick.
What the Hosts File Looks Like Inside
The default Windows hosts file is mostly comments (lines beginning with #) explaining its format. An active entry looks like this:
127.0.0.1 example.com That line tells Windows: whenever something on this machine requests example.com, send it to 127.0.0.1 — the local loopback address, meaning nowhere. This is the standard way to "block" a domain using the hosts file.
You can also map to real IP addresses:
192.168.1.50 mydevice.local This kind of entry is common in home lab or development environments.
Variables That Affect How You Use the Hosts File
The hosts file itself is straightforward, but how useful — or risky — it is depends on several factors specific to your situation.
Technical skill level matters a lot. Editing system files incorrectly can break name resolution for specific domains or, in extreme cases, affect broader network behavior. Users comfortable with the command line tend to have fewer issues.
Windows version and security software can complicate things. Some antivirus or security suites actively monitor and restore the hosts file to prevent malware from hijacking it — a legitimate concern, since malicious software does target this file. If your edits keep disappearing, security software may be overwriting them.
Use case complexity varies widely:
| Use Case | Hosts File Approach | Considerations |
|---|---|---|
| Blocking a few sites | Simple, effective | Manual updates needed |
| Web development / DNS testing | Very practical | Entries must be removed after testing |
| Network-wide ad blocking | Limited — only affects one machine | A dedicated DNS solution scales better |
| Redirecting local devices | Works well for small setups | Doesn't update dynamically |
Administrator access is non-negotiable. If you're on a work-managed machine, IT policies may restrict editing system files entirely — Group Policy can lock the hosts file down or override it.
DNS caching is another layer. Even after editing the hosts file correctly, browsers and Windows itself may cache old DNS results. Running ipconfig /flushdns in an elevated Command Prompt forces Windows to clear that cache and respect your new entries immediately.
🗂️ The Other Files in That Folder
While you're there, you'll notice a few neighboring files — lmhosts.sam, networks, protocol, and services. These are legacy networking configuration files from older Windows architectures. In modern setups they're rarely touched, but they exist in the same directory as the hosts file for historical consistency.
What Determines Whether the Hosts File Is Right for Your Situation
The hosts file is genuinely useful — but it's a single-machine, manually maintained tool. Whether it's the right approach for what you're trying to accomplish depends on how many devices are involved, how often you need to make changes, and whether you have the access level required to edit it reliably. The technical barrier is low for most tasks, but the fit between the tool and the task isn't always obvious until you map out exactly what you're trying to do and on which machine.