You don’t even need to install anything to do this. All you’ll need to do is edit the hosts file which you can probably find in c:\windows\system32\drivers\etc.
How to block sites easily
1. Open up windows explorer and browse to c:\windows\system32\drivers\etc
2. Open up the file hosts with notepad. FYI, hosts is a file without an extension, but its content are merely plain text which you can edit in any text editor such as notepad.
3. In the line directly under
127.0.0.1 localhost
Add the site that you want to block. For example, to block your employees or students from accessing facebook.com, you can do so with:
127.0.0.1 www.facebook.com
4. What this will do is essentially telling all internet browsers to lookup the IP address 127.0.0.1 when a user browse to www.facebook.com. 127.0.0.1 always refers back to the default machine (localhost) and that makes the browser to load up the index page of your local server if you have one setup or simply a blank page if you don’t.
5. As you can see, this trick to block websites is easy to implement, but can be disabled/erased pretty easily as well (just delete the line that you’ve added). I can think of parents using this method to protect their kids from accessing common porn sites, but it would be practically impossible to come up with a list of all porn sites on the web, there are just too many!
Susan says
Question – the file I have is IMhosts – is that the same one? Also, I don’t have a line 127.0.0.1 localhost in that file when I open it in Notepad.
Can I just add 127.0.01 and the site name I want to the end of the text?
I have Windows XP Home Edition running IE 7.
Thanks!
David says
I think you meant lmhosts.sam. Nope, that’s not where you want to add thing into.
hosts is an extensionless file. if you don’t have it, create one. By default, it contains the following content:
Joe says
when i try to save, a dialog box pops up saying “cannot create the C:\windows\system23\drivers\etc\hosts file
Make sure that the path and the file name are correct”
David says
Cant give an answer without knowing what you were doing before getting that error message.
However, the path should be system32, not system23
john says
im having the same problem, any solutions?
Jon says
Same problem as these guys
David says
Are you guys using Vista? The “cannot create the C:\windows\system32\drivers\etc\hosts file” seems to happen in my Vista machine but not on XP.
Anyhow, you can copy the “hosts” file to your desktop, edit it on your desktop and then move it back to C:\windows\system23\drivers\etc\ again. If it ask whether to overwrite, just say yes.
Pal says
Hosts is read-only, make sure to turn that off, and when saving in notepad it defaults to the txt format, select ‘all files’ under type so an extension isn’t added.
Sproc says
If you are using Vista then open notepad as administrator. Right click then Run as administrator. Then open the hosts file. When you are done then save file as hosts but not as a txt file!!!!!!
Carol says
I have
::1 localhost
as the last line and I an getting the same message.
stef says
hi, ive just found this page and am trying to do the same thing, but im stuck at the same point. Any help?
movies says
I love windows 7 because this Windows is the best I’ve had so far installed on your computer.
jean says
hey i think this is an important update: i have windows seven, have this HUUGE project i have to do in 4 days that i was supposed to have been doing for months, so i just found this today to help me not procrastinate sos i can work straight thru the weekend. anyways, with windows seven nothing was working for me, not even when i logged in as administrator. however, i right-clicked notepad and opened as administrator. once there, i opened the host file. i made the adjustments, and saved it. it worked. before i opened it as administrator it wouldnt let me save it. anyways, the story aint over. i found that putting the same numbers (for example 127.0.0.1) for the diff. sites i wanted to block wasnt working, it only worked with the first site. so i changed the numbers for each site, and each written variation of the site url, and then it worked hope this helped someone that was stuck as i was.
netty says
i want to unblock facebook so i tried to just delete the web site from the host file but it will not let me it tells me : make sure that the path and file name are correct …… help please?
David says
sounds like one of those UAC restrictions problems to me
copy the host file to somewhere else (C:\ anything), edit it, and copy it back to the system32/drivers/etc directory (yes, replace the original)
that should do it 🙂
freetibet says
I followed your instructions to the letter, even saving the file after I typed in “127.0.0.1 http://www.facebook.com,” but I can still access Facebook. How come it doesn’t work for me? I am using Win XP 32-bit home edition 2002 version.
sushanth says
i tried to insert to command in the host file.
i have entered 3 websites but i was not able to access 1 website but all others able to access. plz let me know wht to doo
Tan KE says
i use this method and successfully block time wasting websites.
Can i add the time frame for the block such as from 0900-1530?
siroi says
i think the problem with vista that failed ppl to block sites is becoz there’s this “user control thing”.
one need to go to control panel->user account safety->(choose the account with administrator status)->user account->turn user control on or off->turn off uac->ok.
Then follow the procedures given by the mod, make sure u keep the “::1 localhost” in the end like this:
127.0.0.1 localhost
127.0.0.1 http://www.facebook.com
::1 localhost
hope this helps,
Natalie says
I am trying to unblock websites yet when i save the file, it says “Make sure that the path and filename are correct.” Help please? Thanks.
Pau says
RUN AS ADMINISTRATOR
siroi says
for vista, I think you just need to make sure the user control thing is off before you unblock.
NIRAJ BANSAL says
when i try to save the file after editing the file, hosts file is not saving at the same place it is saving at another place in documents.
David says
Can’t you select where it save the hosts file to? It should be saved into the directory Windows/System32/drivers/etc