When managing websites, servers, or testing local environments, having control over how domain names resolve is critical. The hosts file in Windows 10 provides a quick and direct way to map domain names to IP addresses — bypassing external DNS services. Whether you’re a developer, system administrator, or hosting client working with custom environments, this tool can save time and simplify troubleshooting.In this guide , we’ll walk you through what the hosts file does, where to find it, and how to edit it safely.
The hosts file is a local system file used to associate hostnames with IP addresses. When you visit a domain, Windows checks the hosts file before consulting DNS servers. That means you can use it to override DNS settings, block specific websites, or create custom development environments.
Redirect domains to test servers or staging environments
Block unwanted sites (ads, tracking services)
Point a domain to localhost for development
Bypass DNS propagation when launching a new website
You’ll find the hosts file here:
Note: This file has no extension (like .txt) and must be opened with elevated permissions.
You need administrator rights to make changes. Here’s how:
Open Notepad as Administrator (search > right-click > “Run as administrator”)
Click File → Open
Navigate to:
Select “All Files” in the lower-right dropdown
Choose the hosts file
Add your custom entries at the bottom
Save the file
To block access to a domain:
Now, any attempt to open Facebook will be redirected to your localhost — effectively blocking the site.
After editing the hosts file, clear the DNS cache to ensure the new rules apply:
Run this command in Command Prompt (as Administrator).
Problem | Solution |
---|---|
Can’t save the file | Open Notepad as Administrator |
Antivirus blocks editing | Temporarily disable protection or whitelist the file |
Changes not working | Flush DNS cache, restart browser or computer |
If you’ve made changes and something went wrong, here’s the default Windows 10 hosts file:
You can copy and paste this if you need a clean slate.
Use Case | Benefit |
---|---|
Testing new websites | No DNS change needed |
Blocking unwanted sites | Quick and simple |
Internal development | Easily map domains to IPs |
DNS troubleshooting | Isolate and fix resolution issues |