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

Madalina Dinita
by Madalina Dinita
Madalina has been a Windows fan ever since she got her hands on her first Windows XP computer. She is interested in all things technology, especially emerging technologies -- AI and DNA computing in... Read more
Affiliate Disclosure
Windows 10 hosts file editing

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. or localhost: followed by the domain name (e.g. 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.


This article covers:Topics: