Changing the hosts file to prevent the appearance of contextual ads from Google AdSense

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

Typically a “hosts” file contains only one entry which is “127.0.0.1 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 the above case, localhost is the hostname for your computer and it will point to IP 127.0.0.1. IP address and hostname in combination recognize the web presence of any website. AdSense and other contextual ads arise from a particular server (hostnames) that points to a particular IP. Every computer recognizes this unique IP. If you assign your computer’s IP address (127.0.0.1) for each of the hosts serving ads on your website then your computer will point to your IP (127.0.0.1). This will prevent retrieval of actual ads from AdSense, Chitika, and other advertising network servers on 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 “127.0.0.1” while the hostname will vary depending on where your ads appear on your websites. First, write IP “127.0.0.1” followed by “hostname” after giving 2 spaces. Add only one entry per line. This setting will permanently block AdSense, and other specified ads from appearing on your computer web browser. Therefore there are no questions of invalid clicks.

Hosts file

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

Set common IP ( 127.0.0.1) for all hosts.

  • Hostnames to serve Google ads

127.0.0.1  adwords.google.com #[Gmail ads]
127.0.0.1  pagead.googlesyndication.com
127.0.0.1  pagead2.googlesyndication.com #[Google AdWords]
127.0.0.1  syndicate.googlesyndication.com
127.0.0.1  syndicate2.googlesyndication.com
127.0.0.1  googlesyndication.com
127.0.0.1 adservices.google.com
127.0.0.1  syndicate.google.com
127.0.0.1  syndicate2.google.com
127.0.0.1  ssl.google-analytics.com
127.0.0.1  www.google-analytics.com #[Google Analytics]
127.0.0.1  google-analytics.com
127.0.0.1  imageads.googleadservices.com
127.0.0.1  imageads1.googleadservices.com
127.0.0.1  imageads2.googleadservices.com
127.0.0.1  imageads3.googleadservices.com
127.0.0.1  imageads4.googleadservices.com
127.0.0.1  imageads5.googleadservices.com
127.0.0.1  imageads6.googleadservices.com
127.0.0.1  imageads7.googleadservices.com
127.0.0.1  imageads8.googleadservices.com
127.0.0.1  imageads9.googleadservices.com
127.0.0.1  www.googleadservices.com

These changes have other implications as well that you should know before going on this route. Please read below before making a decision.

1. Hosts File Limitations:

  • It only blocks ads served from specific domains listed in the file.
  • Doesn’t prevent ads served from other domains or through alternative methods.
  • Requires constant maintenance to keep up with changing ad server domains.

2. Potential Side Effects:

  • Blocking essential domains could disrupt website functionality or access to other services.
  • Typos or incorrect entries can hinder internet connectivity.

3. Ethical Considerations:

  • Circumventing ad displays can deprive website owners of the revenue they rely on.

Recommended Alternatives:

  • Ad-Blocking Extensions:
    • Install extensions like uBlock Origin, Adblock Plus, or Ghostery for efficient ad blocking.
    • Offer customization options to control which ads are blocked.
  • Browser Settings:
    • Explore built-in ad-blocking features in some browsers.
  • Privacy-Focused Browsers:
    • Consider browsers like Brave or Firefox Focus with built-in ad and tracker blocking.
  • Subscriptions:
    • Support websites you value by paying for ad-free experiences or subscriptions, if available.

Remember:

  • Respect website owners’ right to monetize their content.
  • Prioritize ethical and sustainable ad-blocking methods that support a healthy internet ecosystem.

Leave a Comment

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

Scroll to Top