How to edit Windows 10 hosts file [Step-by-step guide with screenshots]

Raluca Nedeianu avatar. By: Raluca Nedeianu
3 minute read
Windows 10 hosts file editing

Home » Fix » How to edit Windows 10 hosts file [Step-by-step guide with screenshots]

The computer file hosts is a Windows file that translates hostnames to IP addresses. Precisely, it serves the function of converting the hostnames into numeric protocol addresses (IP address), that will locate a host in an IP network. The hosts file has the form of a plain text file.

Before the development of domain name systems (DNS), hosts files were the only solution for the computers to map hostnames to IP addresses. After this process was automated through a DNS, the purpose of hosts file became a bit useless.

Most users of computers do not know that a file called hosts.txt exists. Still, in modern operating systems, his function can be handy. The hosts file remains an alternative name interpretation mechanism and takes priority over the configured DNS server.

Why would you need to edit the hosts file? Most common, to override the DNS settings for a domain or a computer. For example, when you want to block the access to a specific website, from your computer. Or when you transfer a website to a new host provider.

First, you need to move the files to the new server and then shifting the domain to a new IP address. Or maybe, when you do not have a configured DNS server and you need to translate an IP address to a computer name. It’s just easier to use a hostname, than a sequence of numbers (IP address).

Whatever the reason you may have, in this article, we will list  the steps to edit the hosts file on Windows 10.

Steps to edit  Windows 10 hosts file in Notepad

The simplest way to edit the hosts file on Windows 10 is by using the Notepad.

1. Click on the Start button.

2. Search and open a notepad, by right-click and “Run as administrator”.

3. Select File, from the menu. And then Open.

4. You will find the hosts.txt here: “C:WindowsSystem32Driversetc”

5. You need to select “All files” from the drop-down menu, in order to see the hosts.txt file.

6. Then select the file and hit Open.

7. Make the necessary changes in the hosts file. Write just one entry per line.

For example, type the IP address, space (or tab) and then the domain or computer name that you want to use to get to the device/application/website. After these, you can add also a comment (with a # hashtag sign in front).

To block your computer’s access to a specific website, you can use an invalid IP address (e.g. 10.10.10.00 or localhost: 127.0.0.1) followed by the domain name (e.g. www.windowsreport.com) and the comment (e.g. #block site)


8. After you finish, click again on File and Save. Close the notepad.
You can test the changes you’ve made to the hosts file by opening Command Prompt.

Click the Start button and then search cmd. In that window, ping the website that you have blocked. It will return the localhost IP address, that we have added in the hosts.txt.


If you are a programmer that works on websites, you probably need to edit the hosts file again and again. To make things simpler, you can make a shortcut in the Start Menu, that will open hosts file into Notepad, with Administrator rights.

For that, take the following steps:
1. Click the Start menu, search Notepad. Right click on it and choose “Pin to Start”.
2. Once you have the shortcut on the Start menu, you have to right click on it and “Open file location”.
3. Right-click on the shortcut and Properties.
4. In the Target box, it will be filled with “C:Windowssystem32notepad.exe “. You have to add after, the path for the hosts file. It will have to be like this:

“C:Windowssystem32notepad.exe c:windowssystem32driversetchosts”

5. Then click Advanced and in the Advanced Properties, select “Run as administrator”. Hit OK. And in the Properties window, click Apply.

One more thing that you have to know about hosts file is that this file is infested by malware. Through hosts file, viruses corrupt your system and redirect it to other malware ridden website. So if you are trying to cleanse your computer, it’s always a good idea to check the hosts.txt file.

RELATED GUIDES YOU NEED TO CHECK OUT:

Discussions

Next up

How to use the new Reset this PC utility in Windows 10 19H1

Matthew Adams By: Matthew Adams
2 minute read

Microsoft has just showed users a little more of what the 19H1 update has in store for Windows 10. Revamped storage is one of the […]

Continue Reading

How to safely uninstall Steam games on Windows 10

Aleksandar Ognjanovic By: Aleksandar Ognjanovic
2 minute read

We live in an era of digital game distribution and Steam is most likely the king of the hill. However, as the games become significantly […]

Continue Reading

Here’s how to fix Adobe Premiere Pro could not find message

Milan Stanojevic avatar. By: Milan Stanojevic
7 minute read

Adobe Premiere Pro is one of the best video editing tools on the market, but some users reported Adobe Premiere Pro couldn’t find any valid […]

Continue Reading