Various advertising networks strictly prohibit publishers from clicking on contextual ads appearing on their own website. Multiple clicks and impression arising from a few IP address may lead to ban your account. Many publishers have been banned from Google AdSense program because of this. Accidental clicks result while you work on your website for eiditing and modifying and while viewing preview of edited version. Therefore it is very useful to protect yourself form accidental clicks. Changing the hosts file is one of the best ways which permanently remove appearance of contextual ads from chosen places (like Google, Chitika etc).

Typically a “hosts” file contains only one entry that is “ localhost” (see picture below) . In simple layman language, a host can be any website and the hostname always points to a particular unique IP address. In above case localhost is hostname for your computer and it will point to IP IP address and hostname in combination recognize the web presence of any website. AdSense and other contextual ads arise from a particular server (hostnames) which points to a particular IP. Every computer recognizes this unique IPs. If you assign your computer’s IP address ( for each of hosts serving ads in your website then your computer will point to your IP ( This will prevent retrieval of actual ads from AdSense, Chitika and other advertising network servers in your computer. Now next thing is how to change the “hosts” file. Just go to C:\WINDOWS\system32\drivers\etc. Now click on the file named “hosts” with notepad. Now you can add the “IP Address – Hostname” combinations to block ads from various contextual advertising services. Here IP address will always be “” while hostname will vary depending on where from your ads appearing on your websites. First write IP “” followed by “hostname” after giving 2 spaces. Add only one entry per line. This setting will permanently blocks AdSense, Chitika and other specified ads from appearing on your computer web browser. Therefore there is no questions of invalid clicks.

Hosts file
Hosts file

For your convenience, I have listed the recommended setting which you can add to your “hosts” file.

Set common IP ( for all hosts.


  • Hostnames to serve Google ads #[Gmail ads] #[Google AdWords] #[Google Analytics]


  • Hostnames to serve Chitika ads #[IE-SpyAd]

Source: Article first published in Blogger’s Magazine.