Parents always worry about their kids, specially about what they access on the internet. Many people use website blocking softwares to prevent access to specific websites. You can find thousands of such softwares on the internet. But installing a third party software on your PC is not safe always. Luckily, there is a native way using which you can block websites without using any software.
There is a file named as “hosts” in your Windows PC, which allows you to manage local DNS records. Not only Windows, ‘hosts‘ file exists in other operating systems (like Ubuntu etc.) also. You can use this file to control the access to specific websites on your computer.
By making some changes to hosts file, you can block any website on your computer without using any third party software. However, you may need to take ownership of hosts file before making changes to it. You can check following tutorial to know how to take ownership of any file or folder.
After taking ownership, you can modify this file and block websites. IN this tutorial, we are going to block Facebook website using hosts file. First of all, make sure that you can access Facebook on your computer.
How to Block Websites on your PC using Hosts file
First open “My Computer” or “This PC” and go to following path-
You will find some files in that etc folder, one of these will be hosts file. This hosts file is very useful for us as this will help us in blocking the required website without any software.
Now, we need to take ownership of this hosts file. You can check this tutorial for adding ‘Take Ownership’ option in right-click context menu. After that, right-click on hosts file and select “Take Ownership“. By default, users don’t have permissions to modify hosts file but taking ownership will allow us to make changes to it.
You may see UAC Prompt, click Yes to continue.
Command prompt will appear for some time, and will disappear automatically and ownership of this file will be transferred to current user.
Now, open hosts file with notepad. To do that, right-click the hosts file and select Open with.
In Open with pop-up window, select Notepad and click OK.
hosts file will open in Notepad.
After the very last line of the hosts file, add one more line in following format-
Where 127.0.0.1 is loop-back address of your PC and www.facebook.com is the address of the website you want to block. If you want to block more websites, you can add more lines to the hosts file in the same format.
What is Loop-back Address?
Loop-back address is the internal IP address of your Ethernet card. This IP address is used to test your Ethernet card. If you want to test your Ethernet(LAN) card, just ping 127.0.0.1. If ping is successful, then your card is working fine. And above line that we added to hosts file means that your PC will look for Facebook.com on your own computer and not on the internet.
After adding this line to hosts file, save this file and close Notepad.
However, the changes you made in hosts file take effect immediately but sometimes, you may need to reboot your PC for the changes to take effect.
After restarting your computer, open your internet browser and go to www.facebook.com
You see, you have successfully blocked Facebook website using hosts file without any third-party software.
Block Websites on Your PC Without Any Third-Party Software
In the above tutorial, we have successfully blocked the Facebook website on computer. This hosts file method also work with Linux, Ubuntu. So, you can apply the same method on Ubuntu and Linux systems also. You can block any number of websites on your PC by just making an entry in hosts file.
In case you want to undo the changes, simply delete those lines from hosts file and your websites will be unblocked again. Hope you liked the tutorial. Feel free to drop your queries and suggestions in the comment section down below.