How to block a website in Windows 10 and 11
This step-by-step tutorial will show you how to block a website in Windows 10 and 11 by adding a few lines to the Windows hosts file using Notepad.
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, Firefox, Brave, Opera, etc.).
How to block a website in Windows 10 and 11 using hosts file
- Click the Windows start menu button or the search icon in the taskbar.
- Type notepad.
- Right-click on Notepad as soon as it appears in the search results.
-
Click Run as administrator.

- If the User Account Control window appears, click Yes. Depending on your settings, you may also need to enter the admin password and then click Yes.
- Click File in the top left corner of Notepad.
-
Click Open.

- Navigate to the following folder on your PC: (C:) β Windows β System32 β drivers β etc.
- Click Text Documents (*.txt) in the bottom right corner of Notepad.
-
Select All Files (*.*).

- Select the hosts file.
-
Click Open.

-
Add the following lines underneath localhost name resolution is handled within DNS itself:
Replace www.example.com and example.com with the website you want to block (e.g., www.youtube.com, youtube.com).127.0.0.1 www.example.com 127.0.0.1 example.com
- Click File in the top left corner of Notepad.
-
Click Save.

- Close Notepad.
The website is now blocked in all web browsers by the hosts file in Windows 10 or 11.
Note: If the website still opens, close and reopen your web browser to clear its cache, or try opening the site in an Incognito / Private window to test it.
To unblock the website in the future, simply open the hosts file as an administrator again and delete those lines.
Related:
How to block adult content websites on Windows 11 (easy way)
Block websites with NextDNS: Chrome, Edge, Brave & Firefox
How to block a program from accessing the internet on Windows
How to unblock blocked websites (4 safe and free methods)
References:
https://www.wikihow.com/Block-a-Website-on-Your-Computer
https://www.howtogeek.com/784196/how-to-edit-the-hosts-file-on-windows-10-or-11/