Pinterest Stumbleupon Whatsapp
Ads by Google

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 Windowssystem32driversetchosts. 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 :

windows-hosts-file.gif

The first thing you have to notice is the line 127.0.0.1 local host at the bottom. That’s your computer.

Ads by Google

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 :

  • Make sure that the file is still called “hosts” (without a file format at the end such as “hosts.txt”). If Windows attempts to assign a file format to the file, remove it.
  • Do NOT add “http” at the start of the URL. Doing so makes the entry invalid. Just “www” is enough.
  • You will probably have to re-start your browser for the changes to start working and in some cases, it may take a minute or two for the URL to be blocked.

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.

windows-hosts-file.gif 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.

  1. Lilly
    September 14, 2016 at 9:10 pm

    Underneath "127.0.0.1 localhost" is: "::1 localhost"
    what happens now?

  2. Hades
    June 22, 2009 at 2:03 pm

    Do you want to edit the hosts file under Vista?
    Start > All Programs > Accessories > right-click on notepad > Run as administrator.
    Then open the hosts file by browsing to the file location: C:\Windows\system32\drivers\etc
    Make sure all files are shown, not just txt files. Now you can simply open, edit and save the hosts file.

  3. Caleb
    April 21, 2009 at 12:05 am

    How do you add more than one? I'm running windows xp pro and i added the first site, and everything worked, then i hit enter, retyped the ip address then typed another website, it looked exactly the same as the first one, just a line under it, and it won't block the second site. looks like this

    127.0.0.1 http://www.firstwebsite.com
    127.0.0.1 http://www.secondwebsite.com

    the first site is blocked, the second is not, any ideas?

    • Caleb
      April 21, 2009 at 12:07 am

      well this page made my fakewebsites into links, but i just strictly had w w w . f i r s t w e b s i t e . c o m
      without the spacing

  4. sandy
    June 10, 2008 at 1:26 am

    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?

  5. John
    May 9, 2008 at 11:34 am

    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!

  6. John
    May 4, 2008 at 7:33 am

    I am logged in as the administrator, yes. And it's Vista Home Premium.

  7. Karl L. Gechlik | AskTheAdmin.com
    May 3, 2008 at 10:57 am

    John - are you logged in as an administrator? What version of Vista are you running?

  8. John
    May 3, 2008 at 9:05 am

    Well, I opened the file using Notepad, typed the entry in, then clicked Save and that popped up.

    • Mark O'Neill
      May 3, 2008 at 9:58 am

      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.

  9. John
    May 3, 2008 at 8:27 am

    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.

    • Mark O'Neill
      May 3, 2008 at 8:47 am

      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?

  10. earlofpeatrig
    January 12, 2008 at 12:34 am

    Alternatively, you could give this a try:
    scrubit.com/

    • Mark O'Neill
      January 12, 2008 at 11:24 am

      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.

  11. John
    January 8, 2008 at 11:54 am

    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...

    • Aibek
      January 8, 2008 at 9:27 pm

      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. :?

  12. Niyaz PK
    January 6, 2008 at 11:06 pm

    That was a great info. Thx

  13. Travis Quinnelly
    January 6, 2008 at 10:26 pm

    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"

    • Brainiac
      January 8, 2008 at 9:23 pm

      Thanks for the useful tip

  14. Captain Slog
    January 6, 2008 at 9:44 pm

    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.

Leave a Reply

Your email address will not be published. Required fields are marked *