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

Getting Avipbb.sys error on your PC? Fix it with these solutions

Emmanuel Johnson avatar. By: Emmanuel Johnson
5 minute read

Errors like the avipbb.sys can be very frustrating for a beginner to fix. Even some professionals might encounter issues while fixing this error. Having this […]

Continue Reading

Kb4489894 comes with BSOD errors and app launch issues

Rabia Noureen avatar. By: Rabia Noureen
3 minute read

Microsoft releases another batch of cumulative updates for various versions of Windows 10 on the third Tuesday of the month.  Although the update brings plenty of […]

Continue Reading

Microsoft Photos crashes when printing? Here’s how to fix it

Matthew Adams By: Matthew Adams
3 minute read

Photos is Windows 10’s default image viewer that users utilize to browse images libraries and print pictures with. However, some users have stated that Photos […]

Continue Reading