To block YouTube on Windows 10, or any website for that matter, we’d be using what’s called the “hosts file.”
What is a hosts file?
A hosts file is a plain text file that can be used to assign a specific IP address of your choosing for a particular domain, which is also how it can be leveraged to block certain websites, spyware, ads, or QA-ing server migrations. It’s actually quite a useful utility for a simple text file, but any wrong configurations here can adversely affect your ability to connect to the internet.
Luckily, what we’d be doing is something as simple as adding one line of code — while ensuring we’re not making tweaks to the existing. (Nothing too complicated).
Step by Step Instructions on Blocking YouTube or Any Sites on Windows 10
Step 1: First & foremost, you’d have to navigate to your hosts file. By default, almost all hosts file are located at ↣C:\Windows\System32\drivers\etc. In this path, you’d find your hosts file.
Step 2: Assign the loop-back IP address of 127.0.0.1 to the sites you want to block
Without getting into too many technical details for 127.0.0.1, just know that this is something you’d be using.
To do so, after the very end of your hosts file contents, press enter to get to a new line. Then, type:
127.0.0.1 www.youtube.com If you want to block more websites, keep using the same loop-back address, and continue adding similar commands into new lines. For example: 127.0.0.1 www.youtube.com 127.0.0.1 www.facebook.com etc.
See the image below for a visual reference.
Step 3: Save your file. Then, go to your browser and try opening YouTube or other websites that you have blocked. If the new changes have been executed correctly, you won’t be able to access them.
What to Do if You Cannot Save the Changes to Your Hosts File
As hinted earlier in the post, the hosts file is an essential file that, if modified incorrectly, can affect your ability to connect to the internet.
The first rule of thumb to save your new updates to a hosts file is to work on it with administrator-level privileges. The weird part is that Windows won’t let you “run” or “open” it with this access level when you right-click on it.
To circumvent this security measure that Windows 10 has in place, follows the steps below:
Step 1: Search for notepad in your start menu. Then, right-click on it, and select Run as administrator.
Step 2: From the location discussed earlier (C:\Windows\System32\drivers\etc), open your hosts file, make your tweaks, and then save it.
You May Also Want to Check Out:
As demonstrated, blocking sites like YouTube, or any other for that matter on Windows 10 is not difficult. However, the only tricky situation you may run into is that of not being able to save your hosts file.
If so, use the methodology of opening your notepad file as an administrator first, and from there, open your hosts file (versus opening it directly from the location).
All in all, Windows 10 makes it relatively easy to block websites.