Block websites using HOSTS file in Windows

Here is a nice trick that you can use if you want to do some funs with your friends. This trick will block them from access any websites that you specify in the HOSTS file in Windows. But you only can do this trick if you can get access to his/her PC without he/she know. Let say when he/she leave the PC for awhile.

First thing that you need to do is to open HOSTS file which is located at


From there, open up the HOSTS file with notepad and put the sites URL that you wish to block. For an example, I want to block What I do is to put this line

under the localhost like this: localhost

Now what? Ok now go to the internet browser and try go to by typing the URL at the address bar. What you will get is the browser is unable to connect to This is because the DNS for has been changed to instead of the original DNS which is

Extra note: Based from my experience, a virus can edit your HOSTS file and make you unable to connect to the antivirus websites such as,, etc. This purpose of it is to prevent you from do the definition update. In case this thing happens, what you should do is just remove all those lines and you are able to connect to the websites as usual.


  1. Badawi Rocks says:

    this is an old skool method which can be used to block ads.
    especially those nuffnag, advertlets etc.

    google up “hosts file blocking” and go to the 1st site.

  2. Yup. This is an old skool trick. I came across to write this article after a computer at my faculty lab had been infected by a virus. And this virus has edited the HOST file and blocked all antivirus websites. So I hope with this article, people will know how to unblock the blocked websites incase this thing happen to them.

  3. Although this is an old school trick, many people still don’t know about this and a prank can be put on them! :d

  4. nice pranks. if you want to do it in linux, edit /etc/hosts
    the format is still the same

  5. cool tip man. Been suing this for some time now.

  6. Hello everyone, it’s my first pay a quick visit at this web site, and piece of writing is really fruitful in favor of me, keep up posting such articles.