How to disable unneeded error message using hosts file in Google Chrome

Posted on

Problem :

OS=Debian squeeze, browser Google Chrome 15.0.874.106

I use the hosts file to block unwanted sites, especially ad sites, from loading into the browser.
In Iceweasel/Firefox you can block “unable to connect” error messages by going to “about:config” and setting “browser.xul.error_pages.enabled” to false.
Is there a way to get rid of the unwanted error message ( “This webpage is not available” ) in Google Chrome?

Solution :

If you are adding unwanted sites to 127.0.0.1 (I do the same thing), you can try running https://gist.github.com/719843 in the background on port 80 with the flags --port=80 --code=200 and change the line:

server_address = ('', int(options.port))

to

server_address = ('172.20.0.1', int(options.port))

So that it only listens to localhost. It will return 200/Ok for any request with a blank body. This way, you don’t get an error message, but just a blank, and you still get “unable to connect” error messages from other sites when it is legitimate.

Leave a Reply

Your email address will not be published.