Use the Hosts file to Block Sites

As some long-time readers know, I use the pop-up blocker built into the Google toolbar to block annoying ads while I surf the Internet. It’s free (from and it works well. To date, my toolbar has blocked 1,971 windows. That’s a good thing. Unfortunately, it doesn’t block all of the annoying ads I encounter.

Some web sites use various tricks to get around blocking software. In fact, local newspaper sites that shall remain nameless have some particularly annoying pop-under ads that I’m really delighted to never see again. Ads that say things like, “your computer is running slowly” or other supposedly helpful claims are often spyware. You often can tell where these obnoxious flashing banners of badness are coming from by looking at the title bar. Because the ads come from a separate server than the rest of the page, it’s actually relatively easy to block out the offending site. In addition to blocking pop-unders, you also can block sites you don’t want your kids to see.

One way to block sites is by adding entries to Windows’ “Hosts” file. This file is just a plain editable text file that lives on your computer. It has entries that look like:

When you surf to a site, Windows automatically checks to see if the address is located in the Hosts file. The number is the "loop back" IP address of your own computer, so Windows skips the link to the site ( and moves on. The ad server can’t open its window, so it can’t load any programs, spyware, or cookie files either.

You can open the Hosts file in Notepad and edit the entries so the sites you want to avoid are blocked. In Windows XP, the file is located in the C:WindowsSystem32DriversEtc folder. You can learn much more about the Hosts file at this page:

In fact, this page also has a downloadable Hosts file you can use just by copying it into the Etc folder. Or you can view the file to see what evil parasitic sites you want to avoid. The downloadable Hosts file is 318K and the page has a note that says Hosts files that are larger than about 135K can actually slow down your computer.

As a compromise, I just copied out the lines for the ad networks I knew about from the downloaded file into my Hosts file. Over time, I may find more annoying sites, and I’ll just add those entries into the file. Having the download as a reference is really handy, since it has comments that explain what some of the bad sites are up to.

The best news is that I copied in all the lines for the stupid ad network, and it was bye bye pop-unders!

About Susan Daffron

Susan Daffron is the author the Alpine Grove Romantic Comedies and multiple award-winning nonfiction books, including several about pets and animal rescue. Check out all her books on her Amazon Author page.