Home > Windows

How to Block Websites via Hosts file in Windows 11

In this guide, we will show you the steps to block the website of your choice using the Hosts file on your Windows 11 PC. A host file on your Windows PC is used to map hostnames to IP addresses. But that is more along the technical terms. Out of all the plethora of tasks that this file beholds, there’s no denying that its major role is associated with the blocking of websites. Many network administrators usually opt for this method due to its dual benefits involved.

First off, you don’t need to take the help of any third-party app or antivirus. Moreover, many users are now well and aware of the methods to bypass or remove the blocked websites using the firewall or antivirus app. But this host file methodology is something that not many seem to be aware of. All in all, there could be quite a few reasons why one would consider blocking websites using the Hosts file in Windows 11. And in this guide, we will show you how to do just that. So without further ado, let’s get started.



How to Block Websites via Hosts file in Windows 11

block websites in windows 11 using host file

  1. To begin with, launch File Explorer on your PC.
  2. Then head over to the below location:
    C:\Windows\system32\drivers\etc
  3. Now select the Hosts file, right-click on it and select Open With.
    open windows 11 hosts file
  4. Select Notepad from the list and hit OK.
  5. The host file will now open, note down the localhost IP Address. In our case it 127.0.0.1.
    block site via hosts file windows 11
  6. Now to block a website, go to the end of the file and hit Enter to create a new line. Then type in your localhost IP address, press the Tab key for space, and then type in the desired website that you wish to block.
  7. For example, if you want to block the Facebook site, we add the following line at the end of the file [replace localhost IP accordingly, if needed]
    127.0.0.1 www.facebook.com

    block site via hosts file windows 11

  8. If you want to add more than one site, then follow the same command syntax, Just make sure to have one site per line. as an example, let’s block Google and Twitter as well [apart from Facebook]. so the syntax will be;
    127.0.0.1 www.facebook.com
    127.0.0.1 www.google.com
    127.0.0.1 www.twitter.com

    block site via hosts file windows 11

  9. Finally, hit the Ctrl+S shortcut keys to save these changes.

That’s it. These were the steps to block websites using the Hosts file in Windows 11. If you have any queries concerning the aforementioned steps, do let us know in the comments section. We will get back to you with a solution at the earliest.

Share:
  • Open Notepad with: Right click, “Run as Administrator”

  • Can’t even ctrl+s this file. No permission. Even if I give everyone and everythin “full control” permissions.

  • Thanks for your great help.
    I was stuck in a problem and the only way to fix that was through hosts file.

  • What kind of dumbassery is this. The hosts file is an IP-domain map, it has nothing to do with blocking websites

    • Sadique Hassan

      Hi Sarah, what we are doing here is actually assigning the localhost IP to the website that we want to block [instead of the website’s actual IP]. So whenever you type in that website’s URL in the address bar, it will look up to the hosts file and refer to the corresponding IP Address. Since in this case, it is your localhost, it wouldn’t be able to display the actual webpage but would be stuck with this ‘loopback IP Address’.

      Hope it would have cleared your doubts.

    • Did you find how to make it work?

      • Sadique Hassan

        Hi Mate, I have made some tweaks and further simplified this guide. Also, check out my reply to Sarah for further explanation on the same. If you still have any doubts, then do let me know.