Testing of Adsense server in development is tricky, as it’s against Google’s TOS to click on any of your own ads. In any case, UI developers need to see the ad units in order to properly setup layouts and this is how you can enable Adsense and make ad units visible in your localhost testing environment.
For an Asynchronous Adsense setup, you option: data-ad-test=”on”, such as shows in this example:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- YOUR AD NAME --> <ins class="adsbygoogle" style="display:inline-block;width:336px;height:280px" data-ad-client="ca-pub-XXXXXXXXXXX" data-ad-test="on" data-ad-slot="XXXXXXXXXXX"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>
For a Synchronous Adsense setup, you option: google_adtest = “on”; , such as shows in this example (make sure semicolon is present)
<script type="text/javascript"> google_ad_client = "ca-pub-XXXXXXXXXX"; google_ad_slot = "XXXXXXXXXX"; google_ad_width = 336; google_ad_height = 280; google_adtest = “on”; </script> <!-- YOUR SITE NAME --> <script type="text/javascript" src="//pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
If above doesn’t work, other way of fixing the issue is pretending that domain googlesyndication.com sits on your local testing server, and that can be done by editing your host file in windows (typically in C:\Windows\System32\drivers\etc\hosts)
I hope this helps.