How to block internet access to any website on Windows

thumbnail that containing error message in chrome browser this site can't be reached

If you want to block Internet access to a website on a Microsoft Windows computer, you can use the hosts file located in the C:\Windows\System32\drivers\etc directory to block the internet connections to the website.


When you don’t want your children or anyone who uses your Windows computer to access certain websites, the easiest way to force them to follow your rules is to modify the Windows hosts file. However, to be able to edit the Windows hosts file, you need to open the hosts file with administrative right.


This post provides information you need to block internet access to any website on Microsoft Windows.


There are many ways to open a text editor as administrator, you can find your text editor and right click on it and select run as administrator or open command prompt or PowerShell as administrator and type the name of your text editor to open it.


In the command prompt or the PowerShell window, enter the directory that contains the hosts file and type:
notepad hosts
Press enter.


To block access to the YouTube website, type:
127.0.0.1 youtube.com
127.0.0.1 www.youtube.com

save the file.


Every time you will try to access the YouTube website, your browser will send you back to your computer.


I recently published the post Error 1020 access denied, who has resolved the common problem “Error 1020 access denied” when certain IP address try to access content from certain websites.


If you want to block another website, just add a new line. For example, if you want to block internet access to Facebook website, type:
127.0.0.1 facebook.com
127.0.0.1 www.facebook.com

save the file.


How to block internet access to any website on Windows


What To Read Next


If you like the content of this post or if it has been useful to you, please consider sharing it on your social media and follow me on Facebook and Twitter for more exclusive content.