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.
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 8, edit 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 192.168.0.1, you would add this line:
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:
192.168.0.1 printserver scanserver
If you ping either “printserver” or “scanserver”, you’d get to the same IP address:
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 “webserver.domain.com” into the IP address of 220.127.116.11 (this is just an example, actually 18.104.22.168 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 192.168.1.1 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.
More in Windows 10
IT Admins Report Issues With Microsoft Store Version of Quick Assist App
May 16, 2022 | Rabia Noureen
Microsoft Releases May 2022 Patch Tuesday Updates
May 11, 2022 | Laurent Giret
What’s New with Windows – April 2022
May 2, 2022 | Russell Smith
This Week in IT - Is Microsoft Killing Off Patch Tuesday?
Apr 22, 2022 | Russell Smith
Windows 10 November 2021 Update is Now Ready for Broad Deployment
Apr 18, 2022 | Rabia Noureen
This Week in IT - Windows 10 Gets Search Highlights and Is Microsoft in Hot Water Over Windows Cloud Pricing?
Apr 15, 2022 | Russell Smith
Most popular on petri