How to Block Websites on Your PC using the Hosts File

Parents always worry about their kids, especially about what they access on the internet. Many people use website-blocking software to prevent access to specific websites. You can find thousands of such software on the internet. But installing third-party software on your PC is not safe always. Luckily, there is a native way to block websites using the hosts without any software.

There is a file named “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 access to specific websites on your computer.

By making some changes to the ‘hosts’ file, you can block any website on your computer without using any third-party software. However, you may need to take ownership of the ‘hosts‘ file before making changes to it. You can check the following tutorial to learn how to take ownership of any file or folder.

SEE ALSO: How to Enable or Disable Restricted Mode on YouTube to Block Mature Videos?

How to Block Websites on your PC using Hosts file

After taking ownership, you can modify this file and block websites. In this tutorial, we are going to block the Facebook website using the hosts file. First of all, make sure that you can access Facebook on your computer.

Open Facebook in Browser
Open the Facebook website in a browser on your PC

Step 1: Navigate to Hosts File

First, open “My Computer” or “This PC” and go to the following path-


You will find some files in that etc folder, one of these will be hosts file. This hosts file works as a local DNS resolver. It is very useful to block websites without any software or redirect a website to a different address.

Navigate To Hosts File In Your Pc To Block Websites
Navigate to the hosts file on your PC

Step 2: Take Ownership of Hosts File

Now, we need to take ownership of this hosts file. You can check this tutorial to add the ‘Take Ownership’ option to the right-click context menu. After that, right-click on hosts file and select “Take Ownership“. By default, users don’t have permission to modify hosts file but taking ownership will allow us to make changes to it.

Take Ownership Of The Hosts File To Block Websites On Your Pc
Take ownership of the hosts file

You may see UAC Prompt, click Yes to continue. The Command Prompt will appear for some time and will disappear automatically and ownership of this file will be transferred to the current user.

SEE ALSO: How to Manage File and Folder Permissions in Windows?

Step 3: Open Hosts File with Notepad

Now, open hosts file with Notepad. To do that, right-click the hosts file and select Open with.

Right Click On The Hosts File And Select Open With
Right-click on the hosts file and select Open with

In the Open with pop-up window, select Notepad and click OK.

Select Notepad And Click Ok
Select Notepad and click OK

The hosts file will open in Notepad.

Hosts File Open With Notepad
The hosts file

SEE ALSO: How to Disable or Turn off Taskbar Preview Thumbnails in Windows 11?

Step 4: Block Websites using Hosts File

After the very last line of the hosts file, add one more line in the following format-

Where is the loop-back address of your PC and 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 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 on your own computer and not on the internet.

After adding this line to hosts file, save this file and close Notepad.

Block Websites In Hosts File And Save The Hosts File
Block websites and save the hosts file

SEE ALSO: How to Customize Website Notifications in Safari on Mac?

Step 5: Restart your PC

However, the changes you made in the hosts file take effect immediately but sometimes, you may need to reboot your PC for the changes to take effect.

Restart Your Windows 11 Pc
Restart your computer

After restarting your computer, open your internet browser and go to

Website Successfully Blocked Using Hosts File
The website successfully blocked using hosts file

You see, you have successfully blocked the Facebook website using the hosts file without any third-party software.

SEE ALSO: Change these 5 Facebook Settings to protect your Privacy.

Block Websites on Your PC Without Any Third-Party Software

In the above tutorial, we have successfully blocked the Facebook website on the desktop computer. This hosts file method also works with Linux, Ubuntu, etc. 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 the 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 below.

Editorial Staff

Hi there, we are the editorial staff at WINDOSPC (former HELLPC). We are a team of funny and technical people. Feel free to get in touch with us via Contact-Us page.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.