Easily Block Websites and Ads on Windows using HOSTS file [How To]

Discretion and privacy are the most popular trend on the Internet now.  One might not be aware of this, but our every activity is constantly tracked online. Whether it be the websites that you visit, the songs or movies that you stream online, the shopping you do online and much more, all this data is constantly monitored and tracked. One of the most important reason for which your online activity is tracked is because this data is very important to online advertisers. Advertisers use this data to show ads on the websites you visit and these ads are filtered according to your interests and surfing habits.  The privacy of your online activity is very important and you should be aware of how you can protect your activities and identity online.

This simple trick makes use of editing the Windows HOSTS file. HOSTS file in Windows is used to maintain a static table of host-name to IP address mapping and this file is used to locally translate website names to IP addresses.

  1. Manually edit the HOSTS file
  2. Use a tool called Hostsman editor

HOSTS file on your Windows system can usually be found at C:\Windows\system32\drivers\etc\ (where C:\ is the drive where Windows OS is installed). After you have located the HOSTS file, you can use any text editor to edit the file manually.

To block a website, goto the end of the file and make an entry like this :

For example if you want to block Google.com so that it cannot be opened from any browser on your Windows PC, you can make an entry on a new line in the HOSTS file like this:

Once you have made the entries in the HOSTS file, you have to save the file. Also for the changes to reflect instantly, you should clear browser cache and all the browser cookies. You next step should be to clear the DNS cache on your Windows machine. To do this, open a command prompt on your Windows machine and type this:

It is also a good option to restart the machine for changes to take effect. That’s it ! Now when you type the address of a blocked website in any of the web browser on your Windows machine, it will not open.

As can be seen from the screenshot above, if you want to block online ads on websites (e.g. Google ads) you have to make two entries on the HOSTS file: pagead2.googlesyndication.com

2. Editing HOSTS file using Hostsman Editor


If you are looking for an alternate utility other than Hostsman to edit the HOSTS file, you can also make use of Hostess. Hostess specializes in blocking online ads and is very easy to use.

Leave a Reply

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