In order to block some certain sites, I use the following codes in my hosts file:

# localhost name resolution is handled within DNS itself.
#       localhost
#   ::1             localhost http://www.hamdardi.net/  

But that works only when I'm not connected to a VPN.
How can I block a certain website using hosts file even if I'm connected to a VPN?
please avoid suggestions like leechblock for firefox, stayfocused for google chrome. I want a solution that works for all browsers installed on my computer (IE, firefox, google chrome) that doesn't let me to access and edit the blocking settings while the sites are blocked.
I have tried a lot of ways like localfilter, BinarySwitch Eclipse, etc. But I've always found a way to sneak out.
This time I wanna block the sites using hosts file and then set a random password on the file for the administrator of the computer (not the SYSTEM) and give this password to someone else

1 Answer 1


Hosts file should always work - VPN or not. Drop the http protocol. These entries should be sufficient: www.hamdardi.net hamdardi.net

Edit: Useful debugging guide: https://serverfault.com/a/452269

  • Marek Rost is right. Your mistake is that you have written "http://www.hamdardi.net/". HOSTS file only accepts fully qualified domain names, not URLs.
    – user477799
    Jul 30, 2016 at 14:35
  • @FleetCommand but the solution didn't work. I've shared my hosts file content here for you Jul 30, 2016 at 15:02
  • @sepideh as FleetCommander said only FQDNs = fully qualified domain names can be used. You have several errors in the file. As a result your entries are completly ignored. No ports or mapping ip address to ip address is allowed. Same with wildcards, so this line won't work as well: CRL.VERISIGN.NET.*
    – Marek Rost
    Jul 30, 2016 at 15:04
  • 2
    @sepideh hopefully this will help you: nopaste.me/view/49d8ffa7
    – Marek Rost
    Jul 30, 2016 at 15:22
  • 1
    From what i found: it varies case to case - sometimes, when there is error in syntax, it is ignored completly. Another time rules are applied from start of file until the first mistake. This is why i posted that debuggin link into the answer - so you can test it out and see if changes in the file were applied.
    – Marek Rost
    Jul 30, 2016 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.