How to Block Certain Websites in Windows Using Hosts File

You don’t need any additional program to restrict access to some websites on your computer. I will show you how you can use the Windows hosts file to block a web site or more.

One of the most easy and effective ways to block websites in Windows is by using the hosts file. Either to prevent access to adult & entertainment websites, leisure or other sensitive content.

In some scenarios, it is necessary to prevent access to some websites. For example, on your children’s computer, on the work PC, etc. Also, if you want to limit access to certain social networks such as Facebook, Twitter, Instagram, etc.

Whichever the case, you can block as many websites as you need using the Windows hosts file.

Block websites using Windows hosts file

If you have a list of certain websites you want to block from the host file, continue with these steps:

1. Open Notepad as administrator. For this, type Notepad in Start menu search, select Notepad on the results and clic on Run as administrator.

Open Notepad as administrator

2. Once in Notepad, click on the File menu and choose Open.

Open Windows hosts file

3. In the Open window, copy the path C:\Windows\System32\drivers\etc in the address bar and press Enter.

Block websites using hosts file on Windows computer

4. Now, click where it says Text Document (*.txt) and change it to All Files (*.*), so you can see the hosts file.

5. Select the hosts file and click the Open button (or open it with a double click). Then, go to the end of the last line of text and press Enter to add another line (or more times for multiple lines).

6. Next, add the websites to block on the hosts. It must be one per line per site to block, starting with IP 127.0.0.1 and leaving a space between the IP and the page to block.

Block certain websites using Windows hosts file

7. After adding all the sites to block, save changes using the File > Save option or the keyboard shortcut Alt + G.

For example, if you want to block social networks like Facebook, Twitter, YouTube and others in the host file, you can do it as shown in the image above. In this way you could block all the web pages you need, without limits.

Block websites without additional programs

Making use of the Windows hosts file is one of the easiest ways to block websites. The good thing is that this blocking works for all browsers like Google Chrome, Firefox, Edge and others.

Remember that most websites have multiple domains, so an advanced user could find ways to visit blocked sites. For example, if you are restricting access to www.facebook.com, an experienced user could access the mobile version, m.facebook.com.

To avoid this, you must include all the domain variants that can be used to access a particular website.

Scroll to Top