Internet is really a good place to learn a lot of stuff, but equally, it has a real time-wasting and/or dark side where you don’t want your family members or employees to go check out. One simple solution to deal with this problem is to employ some sort of hardware or software solutions which can effectively block unwanted sites, but using these solutions may be expensive and may also require technical knowledge to configure them.
That said, without spending anything extra or without messing with a whole lot of settings, there is a slick way built right into Windows which you can easily use to block or redirect unwanted websites. So without further ado, let us see how to block websites using Windows 8 hosts file.
Note: Even though we are using Windows 8, this trick will work with any previous versions of Windows like 7 & Vista.
What is Windows Hosts File
For starters, Windows Hosts file is a simple system file that is used to override the default DNS behavior. Again, DNS (Domain Name System) is a service which is mainly responsible for mapping the human readable web addresses to its numerical IP addresses. For example, whenever you try to access Google.com you are mapped to its IP address 126.96.36.199.
Windows Hosts file is a local file, i.e, it is specific to your computer. Because it is a local file with certain changes (like the ones shown below), you can easily override default DNS behaviour.
Note: For those who are using Linux, check out the guide here for using the Hosts file in Linux.
Block Websites Using Windows Hosts File
Windows Hosts file can easily be edited using any text editor, e.g. you can use your native Windows text editor Notepad. So let us get started.
1. First off, open your Notepad as an administrator. To do that, open your Start screen and type “Notepad.” Right click on the Notepad app and select the “Run as administrator” option from the list.
2. Once you have opened the Notepad, click on “File” and select “Open” from the list or simply press “Ctrl + O” to open the “Open file” window.
3. Here navigate to:
Once you are there, make sure that you have selected “All files” so that you can see all the files located in the directory. Here select the file named “hosts” and click on the Open button.
4. The above action will open the Hosts file with administrative privileges. Now to block a website you need to add a line just like the one below for each website.
127.0.0.1 example.com 127.0.0.1 google.com
That’s all there is to do. What the above line does is that whenever you try to access “example.com” or “google.com” you will be redirected to the IP address 127.0.0.1. For those who are unaware, 127.0.0.1 (localhost) is a local IP address, and you won’t get anything for that unless you configured your PC to run as a server.
5. Once you have finished editing the Windows Hosts file, press “Ctrl + S” to save the changes and close the Hosts file. The changes are immediate, i.e. no browser or system restart is required. If any user tries to access the blocked URL, they will get the web server not found error.
In the future, if you want to unblock or undo the redirect you can either remove the added line for that specific website or you can comment out of that line by using the “#” symbol at the beginning of the line. Once the symbol is added, it will look something like this…
That said, using the above tip, you can even add your own comments like the reason why you blocked or redirected that specific URL, etc.
That’s all there is to do, and it is that simple to block websites using the Windows 8 Hosts file. Comment below on what you thing of this handy trick.