The internet has lots of benefits but on the other hand, it has its downsides that we all love to hate. The most common one is pop-up ads but if you have young kids who like to surf the net, then as a parent, you will want to protect them from porn sites and any other sites you deem undesirable for such young impressionable minds - such as the Teletubbies.
Well you may not know that it is relatively easy to set up your own internet filter to stop certain websites and pop-up windows from being accessed and shown on your computer - and it already resides on your Windows operating system in the form of the Hosts file. Just adding a line to the file can stop a website or a pop-up window in its tracks.
The Hosts file is located at Windows\system32\drivers\etc\hosts. The file has no file format so when you double-click on it, you’ll be asked how you want to open it. Just choose Notepad to open the file as a text file. If you are not so experienced in dealing with the Hosts file, you may want to make a backup of this file before you start altering anything.
When it is opened, this is what you will see :

The first thing you have to notice is the line 127.0.0.1 local host at the bottom. That’s your computer.
To block a website from your browser is very easy. Say you suddenly develop an overwhelming hatred for Google and you want to banish them to the internet graveyard. Time to give it the Hosts file treatment!
On the bottom line of the file (underneath 127.0.0.1 local host), just type :
127.0.0.1 www.google.com
Save it and close the file. But there are three things to make sure of to ensure this works properly :
Now try to access the site in question. You’ll see that you now get a blank page. Totally inaccessible. Every attempt to access the URL just gets automatically bounced back to you with the blank page.
If you suddenly decide you’re madly in love with Google again, just open up the Hosts document again and delete the line you just inputted. Save and close the file, then re-start the browser. Google will suddenly become available again.
So how does this stop block-up ads? Well when the ad comes up on your screen, take a note of the URL that it is coming from and add it to your Hosts file. Save and close then go back to the website in question. You’ll suddenly find that pop-up ad doesn’t appear anymore!
Now you’re probably saying that with pop-up blockers being standard in browsers these days, what’s the point of this? But pop-up blockers are not 100% perfect. I know of one website that overpowers the pop-up blocker and loads up pop-up windows without any resistance from Firefox or the Google toolbar pop-up blocker. So sometimes you need a little more than your browser to stop those nasty critters.
If you do a Google search, you’ll find people who have compiled lists of malicious URL’s that you can add to your Hosts list. This includes pop-up ads, spyware, trojan horses and porn. But I prefer to just add to the Hosts file myself on a site-by-site basis. Creators of these URL lists can get a bit carried away with privacy and end up giving us URL’s that can block sites we may consider legitimate. So I think it’s best to do it yourself.
So if you have essential sites constantly popping ads up at you or if you want to filter out naughty sites from your kids, the Hosts file is a fairly simple way of doing it.
Filed Under: Browser ¦ How-To ¦ Windows
Tags: How-To, safer browsing, security, windows tips
You neglect to add one very important fact. A HOSTS file is zero footprint; it uses no memory. As opposed to all those toolbars that help to swamp a system’s resources (Hey under Vista we don’t have enough as it is) a HOSTS file is a great way to block unnecessary pages dead. Also, a great idea is to have a backup of your HOSTS file as well as to set it to read only.
You’re right Captain Slog, it is a perfect zero footprint solution.
FYI:
After saving changes to the hosts file, you should also be able to use nbtstat -R which purges and reloads the remote cache name table to avoid having to restart your browser or computer.
Start -> Run “nbtstat -R”
Thanks for the useful tip
That was a great info. Thx
[...] Via | makeuseof.com [...]
I use hostsman to manage my hosts file and keep it updated with many hosts file sources for site blocking
http://www.abelhadigital.com/
Since adblock plus, my net surf has never been better…
I am a bit confused. Why would you use both of these tools? As it seems to me both of them do the same thing.
Alternatively, you could give this a try:
http://www.scrubit.com/
Yes, that is a possibility but do you really want other people / companies deciding for you what’s a “suitable site” and what isn’t? Everyone has their own tastes / standards / opinions.
I much prefer to make that distinction for myself by manually blocking sites on my own.
I tried this and it says
“Cannot create the C:\Windows\system32\drivers\etc File.
Make sure the path and file name are correct”
Can anyone offer some help? I’m running Vista and am the Administrator on the computer.
John : I don’t have Vista as my OS so I can’t say where that message has come from. However I am confused. You would normally open and edit the Hosts file using a text editor. So where is that error message coming from?
Well, I opened the file using Notepad, typed the entry in, then clicked Save and that popped up.
Sorry John, not having Vista, I can’t help you out there. I am totally mystified. I’ll ask Karl who may be able to help.
John - are you logged in as an administrator? What version of Vista are you running?
I am logged in as the administrator, yes. And it’s Vista Home Premium.
Well, I took the advice of the above other John and am now using Hostsman to manage the Hosts file. It works fine. Thank you for your help, anyway, much appreciated!
Hey friends, that is fine for blocking URL’s. But if I want to add URL for gmail for resolving the names in HOSTS file itself what needs to be done?