Block ANY Website in ALL Browsers using Windows Hosts File

Do you know that you can completely block certain websites from opening in ANY browser (Firefox, Google Chrome, Internet Explorer, Opera or Safari) present in ANY Windows User Account viz. Administrator, Limited (Standard) and Guest? This can be easily done by editing the Hosts File.

How to block domains and sub-domains?

Suppose you want to block on your computer running Windows 7, so that NO User can access it. Following are the steps to do so:

1. The Hosts File in Windows 7 is located at C:\Windows\System32\drivers\etc\ (Assuming you have installed the OS in C: Drive). Copy this location in your clip board:

windows 7 hosts file location

2. Click on Start Button >> All Programs >> Accessories and look for Notepad.

3. Now Right Click on Notepad and Select Run as Administrator:

notepad run as administrator

4. Click Open (CTRL + O) in Notepad and Paste the Hosts File Address in the File Name field >> Press Enter and Select All Files from the Drop Down Menu >> Now, Click on Open Button:

windows 7 hosts file

The file will get open in Notepad and as shown in the Video above, you are required to enter following line at the bottom of the File:<PRESS TAB KEY><SPACE>

For blocking Multiple Websites, enter as follows:<TAB KEY><SPACE><TAB KEY><SPACE><TAB KEY><SPACE>

If you want to block a sub-domain, then enter as follows:<TAB KEY><SPACE>

5. Click on File Menu and Hit Save to make the changes.

Conclusion: The domain name you just entered after (also know as Loopback IP Address) in Hosts File will NOT open in any Browser, unless you undo the changes.


  • In Windows 7, Notepad running in Administrator Mode can ONLY save the changes you made in Hosts File. You cannot Save the file, if you run the application in normal mode.
  • In Windows Vista and 7, if you get a UAC Prompt then you need to click on Continue button. In case, you get an Error while modifying Hosts File, then check out THIS Article from Microsoft.
  • Since there’s No Administrator Mode in previous versions of Windows viz 98, 2000, ME, NT, Vista and XP, you can edit the Hosts File directly in them using Notepad. The location of hosts file in these also remains same i.e. C:\Windows\System32\drivers\etc\
  • There are many software available on the Internet (like Firewall) which can easily block access to unwanted websites. But, Advanced Users can easily end the Process Tree of these software from Windows Task Manager and other similar task killing programs.
  • Try to allot Limited and Guest Accounts to other users who uses your computer. This will prevent them from editing Hosts File, as it requires Administrator Password in Notepad.
  • Some Security Software like Anti-Virus, Firewall etc. may not allow you to change the content of Hosts File. You are required to temporarily disable their LIVE protection.

3 replies on “Block ANY Website in ALL Browsers using Windows Hosts File”

This is great! Now I can limit the sites when someone use my computer. Thanks a lot

Great article but it seems the user has found a way around this.
They are using and, and probably others too!

Is there a wildcard like * that can work? I tried that but it doesn’t work.

Another question, can we make it go to our company website instead of page cannot be displayed? I pinged our website and substituted with that IP but it doesn’t work. I’m no expert on hosts files so I was just guessing it might work.

Any help would be GREATLY appreciated!



Hi Tom,

You can block websites using your router as well. You can either block a keyword or a domain name from your router’s settings page. I have already made a video about “How to Block ANY Website or a Keyword using Wi-Fi Router”:

You can also block websites using various Parental Control Software available on the internet. Some of them are KIS, Bitdefender, K9 Web Protection etc.

Regarding blocking Facebook sub-domains and webpage redirection, I will have to work on these things first. I will post an update if I am able to find a solution.

Comments are closed.