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.

 What Is the Hosts File?

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.

Common Use Cases:

  • 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

Where Is It Located?

You’ll find the hosts file here:

C:\Windows\System32\drivers\etc\hosts

Note: This file has no extension (like .txt) and must be opened with elevated permissions.

How to Edit the Hosts File in Windows 10

You need administrator rights to make changes. Here’s how:

 Step-by-Step

  1. Open Notepad as Administrator (search > right-click > “Run as administrator”)

  2. Click File → Open

  3. Navigate to:

    C:\Windows\System32\drivers\etc\
  4. Select “All Files” in the lower-right dropdown

  5. Choose the hosts file

  6. Add your custom entries at the bottom

  7. Save the file

 Example Entry:

127.0.0.1 testsite.local
192.168.88.200 dev.yourdomain.com

How to Block a Website Using the Hosts File

To block access to a domain:

127.0.0.1 facebook.com
127.0.0.1 www.facebook.com

Now, any attempt to open Facebook will be redirected to your localhost — effectively blocking the site.

Apply Changes: Flush DNS Cache

After editing the hosts file, clear the DNS cache to ensure the new rules apply:

ipconfig /flushdns

Run this command in Command Prompt (as Administrator).

Common Issues & Fixes

ProblemSolution
Can’t save the fileOpen Notepad as Administrator
Antivirus blocks editingTemporarily disable protection or whitelist the file
Changes not workingFlush DNS cache, restart browser or computer

 Resetting to Default

If you’ve made changes and something went wrong, here’s the default Windows 10 hosts file:

# Copyright (c) Microsoft
127.0.0.1 localhost
::1 localhost

You can copy and paste this if you need a clean slate.

Summary: Why the Hosts File Still Matters

Use CaseBenefit
Testing new websitesNo DNS change needed
Blocking unwanted sitesQuick and simple
Internal developmentEasily map domains to IPs
DNS troubleshootingIsolate and fix resolution issues