How To Use Your HOSTS File

You have a file on your computer which, if you know how to edit and use, you can use to do things like block advertising from certain websites or even block certain websites altogether. For example, if your computer keeps downloading ads from a particular source and you hate it, you can block content from that server. OR if you are trying to keep your kids from going to a certain website, you can block them from visiting it (unless, of course, they are very bright kids who know how to get to yorur HOSTS file).

Here is where you will find your HOSTS file:
Windows XP–C:\\Windows\\System32\\Drivers\\etc
Windows 2000–C:\\Winnt\\System32\\Drivers\\etc
Windows 98 and ME–C:\\Windows

This file is used for instructions on where to route your browser when certain addresses are entered. When you visit a website, your computer first checks the HOSTS file for an IP address. If it does not find one, it will go to the domain name server. So, for example, people who use IIS or PWS on their computers can type in "localhost" and it will be brought to their own computer, IP 127.0.0.1. This is because localhost is defined in your HOSTS file to go to that IP address.

You can block other sites by entering their URL in the HOSTS file and routing them, too, to 127.0.0.1. So, for example, if you wanted to block ads from trafficmarketplace.com, you would enter the following line in your HOSTS file:

127.0.0.1 trafficmarketplace.com

Free eBook!

Like what you read?

If so, please join over 28,000 people who receive our exclusive weekly newsletter and computer tips, and get FREE COPIES of 5 eBooks we created, as our gift to you for subscribing. Just enter your name and email below:

Post A Comment Using Facebook

Discuss This Article (Without Facebook)

One comment

  1. Carlton Dunaway /

    I tried to run the hosts file command, and was told it did not exist. ???

Leave a Reply

PCMech Insider Cover Images - Subscribe To Get Your Copies!
Learn More
Every week, hundreds of tech enthusiasts, computer owners
and geeks read The Insider, the digital magazine of PCMech.

What’s Your Preference?

Daily Alerts

Each day we send out a quick email to thousands of PCMECH readers to notify them of new posts. This email is just a short, plain email with titles and links to our latest posts. You can unsubscribe from this service at any time.

You can subscribe to it by leaving your email address in the following field and confirming your subscription when you get an email asking you to do so.

Enter your email address for
Daily Updates:

Weekly Newsletter

Running for over 6 years, the PCMECH weekly newsletter helps you keep tabs on the world of tech. Each issue includes news bits, an article, an exclusive rant as well as a download of the week. This newsletter is subscribed to by over 28,000 readers (many who also subscribe to the other option) - come join the community!

To subscribe to this weekly newsletter simply add your email address to the following field and then follow the confirmation prompts. You will be able to unsubscribe at any time.

Enter your email address for
Free Weekly Newsletter: