The Windows Hosts file is the file that Windows uses to manage and map IP addresses. By editing the Hosts file, you can configure Windows to block or redirect specific websites and even the protocols used by programs and applications.
To start editing the Windows hosts file, you first need to find it. Open Windows Explorer and click This PC or My Computer. Double click C: then Windows folder and scroll down the page until you reach the System32 folder. Inside that folder, open the drivers and then open etc. Now you will see several files, one of which is hosts.
Now, notice that the file type for the hosts file is listed as File. Since there is no default program to open this type of file, double-clicking on the hosts file will simply prompt you to Windows asking which program you want to use to open the file.
In this request, you can edit the hosts file using Notepad. So, just click to select Notepad and click OK. From there, Notepad will launch with information about the hosts file.
This way of opening the hosts file was demonstrated to show where the hosts file is actually located in Windows, but you won’t be able to edit it because it’s a system file. To edit the file, you must first open Notepad with administrator rights.
Click Start and type Notepad, but don’t click Notepad to open it. Instead, right-click the Notepad list to open the context menu. Select the “Run as administrator” option.
With Notepad open, select File> Open. Go to C: Windows System32 drivers etc . You will see a blank screen displaying a prompt No items matching your query. Change Text Documents (* .txt) to All Files using the dropdown menu. Now you can select the hosts file and click Open.
It is very easy to add files to the hosts file. The hosts file uses the format:
IP address exampledomain.com
To block a website on Windows, just enter the following at the end of the hosts file:
So, if I wanted to block a website like www.nytimes.com, I could simply add the following line:
We are actually telling Windows that the www.nytimes.com website should redirect to the IP address 127.0.0.1, which is just a loopback address on our local system. If you don’t have a local website set up on your computer, you’ll just get an error page in your browser.
Pretty cool, huh !? Obviously, you can see how it can be used in different ways: prank, parental controls, etc. If you didn’t want to block a website this way, you can also redirect it to another website. To do this, you first need to find the IP address of another site.
To do this, simply open Command Prompt (click Start and type CMD) and enter the following command:
In my example, I sent a request to Adobe.com. IP address 184.108.40.206. Now I can just paste this number into my hosts file in front of www.nytimes.com.
Now when I visit www.nytimes.com I am redirected to Adobe.com! Nicely! Please note, if this does not work for the websites you enter, it might be related to the url you are using. For example, it matters if you use www.nytimes.com as opposed to nytimes.com without www. Visit the website and see exactly which URL of the website you want to redirect. You should always try without www first to see if that works.
If the website is using HTTPS like Google.com or something, it should still redirect if you are using the hostname. It is not possible to specify the HTTPS version of the website in the HOSTS file, but it should redirect the HTTPS and non-HTTPS versions of the website if you are only using the hostname (e.g. google.com).
Finally, you can use the hosts file to create simple shortcuts for your own devices on the network. For example, my router is on my home network at 192.168.1.3, but I could add the following line to my hosts file and just type myrouter.com into the address bar.
It doesn’t really matter if myrouter.com is a website or not, because the hosts file is read first and you will be redirected to the IP address specified in the file. It’s worth noting that not all browsers are able to use the hosts file, so if it doesn’t work it could be a problem. I tested it with IE, Microsoft Edge, Chrome and Firefox and it worked in all browsers.
Overall, the hosts file is still useful even on Windows 10. It also works great on Windows 8, 7, Vista, etc. If you have any questions, feel free to comment. Enjoy!