Edit Windows Hosts File: A Comprehensive Guide

Mary Aug 04, 2026

Ever found yourself in a situation where you need to tweak your system's DNS settings for testing purposes or to bypass geo-restrictions? The Windows host file, a often overlooked yet powerful tool, can help you achieve this. It's a plain text file that maps hostnames to IP addresses, and editing it can temporarily override your system's DNS lookup process.

HostsMan: Edit, Restore, Manage And Merge Multiple Windows Hosts File
HostsMan: Edit, Restore, Manage And Merge Multiple Windows Hosts File

Before we dive into the "how", let's understand why you might want to edit the Windows host file. Imagine you're trying to access a website that's blocked in your region, or you want to test a new domain in development. Instead of using a third-party service or a complicated proxy setup, you can simply edit your host file for a quick and easy solution. But be cautious, editing the host file can potentially disrupt your system's functionality if not done correctly.

What Is the Windows Hosts File and How to Edit It - Make Tech Easier
What Is the Windows Hosts File and How to Edit It - Make Tech Easier

Locating the Windows Host File

The Windows host file is located in the system root directory, usually hidden from plain sight. Here's how to find it:

How to edit HOSTS file on Windows 11, 10 - Pureinfotech
How to edit HOSTS file on Windows 11, 10 - Pureinfotech

1. Open File Explorer and navigate to the C drive or the root directory of your primary hard drive.

2. Type "C:\Windows\System32\Drivers\etc" in the address bar of the File Explorer window and press Enter.

How to Locate and Edit Hosts File on Windows
How to Locate and Edit Hosts File on Windows

Turning Off Hidden File View

Before you can see the "hosts" file, you need to ensure that Windows isn't hiding it.

To do this, follow these steps:

How to Edit Hosts File on Windows 10
How to Edit Hosts File on Windows 10
  1. In the "etc" folder, click on the "View" tab, then select "Options" > "Folder and search options".
  2. In the "Folder Options" window, click on the "View" tab, then scroll down and select "Show hidden files, folders, and drives". Also, uncheck "Hide protected operating system files (Recommended)".
  3. Click "Apply" and then "OK".

Opening the Host File in Notepad

Now that you can see the "hosts" file, you need to open it in Notepad to edit it.

Stupid Geek Tricks: Create a Shortcut to Quickly Edit Your Hosts File
Stupid Geek Tricks: Create a Shortcut to Quickly Edit Your Hosts File

Here's how:

  1. Locate the "hosts" file, right-click on it, and select "Open with" > "Notepad".
  2. If prompted with a warning, click "Yes" to grant Notepad permission to make changes to the file.
How to Edit the Hosts File in Windows 10
How to Edit the Hosts File in Windows 10
the screenshot is showing that there are many folders in this file, and it's not very easy to use
the screenshot is showing that there are many folders in this file, and it's not very easy to use
What Is the Hosts File, and How Do You Edit It in Windows?
What Is the Hosts File, and How Do You Edit It in Windows?
an image of the windows xp theme in this screenshote screengrafii
an image of the windows xp theme in this screenshote screengrafii
Get IP Addresses Of Domains & Block Or Activate Them: Hosts Editor
Get IP Addresses Of Domains & Block Or Activate Them: Hosts Editor
Editing the hosts File on Windows
Editing the hosts File on Windows
How to Hide Files and Folders in Windows 11
How to Hide Files and Folders in Windows 11

Editing the Windows Host File

Now comes the fun part - editing the file. First, let's discuss the structure:

The "hosts" file begins with "#" symbols that indicate comments and blank lines that separate sections. Each line that doesn't start with a "#" has two columns: IP address and hostname. The IP address column is for the IP address you want to route to, and the hostname column is for the hostname you want to point to that IP address.

Adding an Entry to the Host File

Say you want to point "example.com" to "192.168.1.1". Here's how:

1. Open the "hosts" file in notepad.

2. At the very end of the file, add the following line:

"192.168.1.1 example.com"

3. Save the file and close Notepad. Restart your browser to see the changes.

Removing an Entry from the Host File

If you've added an entry and want to remove it, follow these steps:

1. Open the "hosts" file in notepad.

2. Locate the line you want to remove.

3. Delete the entire line, including the leading IP address and trailing hostname.

4. Save the file and close Notepad. Restart your browser to revert to your default DNS settings.

A Word of Caution

Editing the "hosts" file can disrupt your system's normal functioning. It's essential to revert the changes you've made when you're finished, as leaving them unchanged could lead to unexpected DNS lookups or potentially hinder your ability to connect to the internet.

Remember, when editing this file, it's crucial to be aware of the changes you're making. A misplaced entry could send you to the wrong website, potentially putting your security at risk.

In the world of DNS manipulation, the Windows host file serves as a handy, quick, and dirty tool. It offers a simple way to point domains to different IP addresses, even though it's not meant for permanent use. So, the next time you need to change DNS settings for testing or bypassing geo-restrictions, you know where to find the help you need.