Windows OS

How to Block YouTube on Windows 10 (or Any Website)

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.

location of windows 10 hosts file
As a first step, find your hosts file.

Step 2: Assign the loop-back IP address of to the sites you want to block

Without getting into too many technical details for, 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:
If you want to block more websites, keep using the same loop-back address, and continue adding similar commands into new lines. For example:

See the image below for a visual reference.

blocking youtube via hosts file
This is how you block YouTube on Windows 10 (at least, one of the easiest ways).

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.

running notepad as a administrator
As displayed, open your notepad as an administrator.

Step 2: From the location discussed earlier (C:\Windows\System32\drivers\etc), open your hosts file, make your tweaks, and then save it.

opening a file in notepad
Rather than opening your hosts file directly from the location, open your notepad as an administrator first, and then open your hosts file.

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.