If you are system administrator at a school, college or office, then you must be looking for a good way to block useless websites like orkut, myspace, facebook, twitter etc. from the computers. Or if you are a parent, then you may want to block certain websites from your computer so that you children don’t open them by mistake.
The best solution would be to use some commercial software to block these websites. Another way would be to configure a proxy filter at the network gateway. Both these solutions are the good ways to block websites. But if you are looking for a cheap solution (read Free) which involves little or no technical expertise, then you can use HOSTS file to block websites.
How To Use Hosts File To Block Websites?
1. Open hosts file in a text editor.
The location of hosts file depend upon your operating system,
- For Windows NT/2000/XP/2003/Vista/7, it is %SystemRoot%\system32\drivers\etc\
- For Windows 95/98/Me, it is %WinDir%\
- For all flavours of Linux and unix, it is located at /etc/hosts
- For Mac OS 9 and earlier, go to System Folder->Preferences
- For Mac OS X, it is located at /private/etc/hosts
If you are on windows vista or windows xp, go to click on start->run type, notepad %SystemRoot%\system32\drivers\etc\hosts, and press enter.

For other operating systems, simply open the hosts file in any text editor.
2. When the hosts file is open, just look for the line,
127.0.0.1 localhost
Now under this line, add the names of website that you ant to block, in the following format,
127.0.0.1 websiteToBlock
For instance, if you wish to block twitter from your computer, then the following files must be added to the hosts file,
127.0.0.1 www.twitter.com
127.0.0.1 twitter.com

After adding all the websites that you want to block, save the file. Now try to open the blocked websites in your browser. Yes, it works :)
To unblock the websites again, simply remove those lines from hosts file.
Following is the video demonstration of blocking websites with the help of hosts file -

wow does work thanks a lot!!!
wow it is working and would be a good trick for me
For Vista/Win7:
Start – run – cmd – (right click ‘run as administrator’)
In the command prompt type:
notepad %SystemRoot%\system32\drivers\etc\hosts
@shadowking
Thanks for the updates on Windows 7.
I dont know what to do i got windows 7 i want to block facebook
Can somebody please help me how to block facebook?
never mind i got it. WOW it works! YESSSS!
Hiya i have tried this, but it just says access to C:\windows\system32\drivers\etc\hosts was denied. HELP!!!
@Lesley
See this tutorial, http://www.hacktrix.com/how-to-edit-hosts-file-in-windows-vista
thankz it’s work..
thanks bro
Thank you so much sir….horray…..Love it. Now, my part time hire cannot
have fun time when I am not here
GREAT IT WORKSSSSSS…… :))))
I have this problem in my office and using Clear OS (firewall). Still failed to block even though suggested me to change setting in Local DNS server…
but when i do this the whole user in the network was block. But with this command,limited users does not have the privliges to change the command lines.
Well done…now i can relax as the band with is no longer clogged up.
plz help me …
the file host is not getting saved on its original location ,it asks to have permission from administrator..and saves on other location
@abdul
Check this tutorial http://www.hacktrix.com/how-to-edit-hosts-file-in-windows-vista
in my windows 7 says i dont have permision to save in this location. help
@tony77
Please check this tutorial, http://www.hacktrix.com/how-to-edit-hosts-file-in-windows-vista
wah………… thanx a lot
a lot of thanx!
it’s really works , it is great!
It is very easy to block unwanted sites