How to block a website in Windows 10 and 11

This tutorial will show you how to block a website in Windows 10 and 11.

You don't need third-party software to block websites in Windows 10 or 11. You can do this by adding a few lines to the Windows hosts file using Notepad.

The website will be blocked in all web browsers (e.g., Google Chrome, Microsoft Edge, Mozilla Firefox, Brave, Opera, etc.).

How to block a website in Windows 10 and 11 using hosts file

1. Click on the start menu button.

Windows 11 start menu button

2. Type notepad.

3. Right-click on Notepad when it appears in the search results and then click on Run as administrator.

Open Windows Notepad as administrator

4. If the “User Account Control” window appears, you click Yes. Depending on your settings, you may also need to enter the admin password and click Yes.

5. Click on File located in the top left corner of Notepad and then click on Open.

Windows Notepad open file

A small window will appear.

6. Navigate to the following location on your PC: (C:) > Windows > System32 > drivers > etc.

7. Click on Text Documents (*.txt) located in the bottom right corner of Notepad and select All Files (*.*).

Select All Files in Windows Notepad

8. Select the hosts file.

9. Click on Open.

Open Windows hosts file in Notepad

10. Add the following lines underneath localhost name resolution is handled within DNS itself:


127.0.0.1	www.example.com
127.0.0.1	example.com

Replace www.example.com and example.com with the website you want to block (e.g., www.youtube.com, youtube.com).

Block a website in Windows 10 using the hosts file

11. Click on File located in the top left corner of Notepad and then click on Save.

Save the Windows Hosts file in Notepad

The website is now blocked in all web browsers by the hosts file in Windows 10 or 11.

12. You can now close Notepad.