Windows 10

Easily Edit the Hosts File in Windows 10

Most operating systems, including Microsoft Windows versions, use the hosts file to translate computer names. Also known as “host names” to numerical IP addresses, the hosts file is similar to using a phone book to find the matching phone number of a specific person’s name.

Note: This article was written at the time when Windows 10 was at Technical Preview build phase.

While Domain Name System – or DNS – is mostly used for this function (being a centralized and half-automatically managed name resolution system), the HOSTS file can be used as a local name resolution mechanism, and when used in conjunction with other name resolution mechanisms such as DNS, the HOSTS file takes precedence over them.

This is why many users still edit the HOSTS file and add names and IP addresses of servers, websites and other computers they frequently access to it.

Sponsored Content

Passwords Haven’t Disappeared Yet

123456. Qwerty. Iloveyou. No, these are not exercises for people who are brand new to typing. Shockingly, they are among the most common passwords that end users choose in 2021. Research has found that the average business user must manually type out, or copy/paste, the credentials to 154 websites per month. We repeatedly got one question that surprised us: “Why would I ever trust a third party with control of my network?

Location of the Hosts File

In Microsoft operating systems, the HOSTS file is located in the following location:


Note: We also have tutorial articles on how to edit a hosts file in Windows 8edit a hosts file in Windows 7 and on a mobile device running Windows RT.

How the Hosts File Works

The HOSTS file is a text file, one that does not have a file extension. It contains lines of text that are made of IP addresses followed by one or more host names or fully qualified domain names (FQDNs). Each field is separated by white space (blanks or tabulation characters).

For example, if you wanted to use the HOSTS file to translate a host name of a computer called “printserver” into the IP address of, you would add this line: printserver

You can add more than one host name to the same IP address. For example, if the computer called “printserver” also acts as a scanner called “scanserver”, you could use this line: printserver scanserver

If you ping either “printserver” or “scanserver”, you’d get to the same IP address:

Edit the HOSTS File in Windows 10


The HOSTS file can also translate Fully Qualified Domain Names (or FQDNs) of computers, such as ones used on the Internet.

For example, if you wanted to add a manual line to translate a FQDN of a computer called “” into the IP address of (this is just an example, actually is the IP address used by Google’s DNS servers), you would add this line:

When you ping it, your computer will resolve the name to the correct IP address:


You can also include comment lines by placing a hash character (#) at the beginning of the line.

This is how the HOSTS file looks on a Windows 10 Technical Preview build machine:


The HOSTS file may sometimes be used by malicious software such as adware, computer viruses, or trojan horses etc. These applications may use it to redirect traffic from the intended destination to sites hosting malicious or unwanted content. That is why some Anti-Virus programs may monitor changes to the HOSTS file, preventing malicious software from modifying it. So does Windows, and unless you use elevated permissions to edit the file, you will be prevented from saving it.

How to Edit the Windows 10 Hosts File

To edit the HOSTS file we need to use a method that allows us to save the file to it’s original location, which is:


1. To do so, copy the HOSTS file to your Desktop.


2. Open the copy from your Desktop in Notepad.



3. Make all necessary changes. For example, adding a line that translates to “kuku”. Save the copy.


4. Next, copy and paste the file to its original location.


5. You will be asked if you want to overwrite the file. Choose Replace the file in the destination.


6. Windows will ask for Administrator permissions. Click Continue.


7. The changed HOSTS file will replace successfully the original, and now, if you ping “kuku” you will get the corresponding IP address.





Related Topics:


Don't have a login but want to join the conversation? Sign up for a Petri Account

Comments (3)

3 responses to “Easily Edit the Hosts File in Windows 10”

  1. Or you can run Notepad as an administrator and edit the file directly, like we’ve been doing for several years in Windows 7 and Server 2008 R2.

  2. I wish Microsoft would wise up and will display UAC prompt for file access to restricted locations. Copying files back and forth between desktop and destination directory PIA.

Leave a Reply