ERR_CONNECTION_REFUSED for localhost addresses on Chrome

I run my development environments with a Vagrant VM for each, with each project mapped to *.localhost in /etc/hosts. So I can access project1.localhost, project2.localhost, etc.

Unfortunately as of yesterday, these addresses all completely stopped working in Chrome, instead giving an ERR_CONNECTION_REFUSED message. The strange thing was that I could still access the project directly by IP, and the *.localhost addresses still worked perfectly in Safari and Firefox.

It actually turns out that this is a new security feature introduced in Chrome 43, which blocks any subdomains of localhost from being accessed from the web. Specifically this means URLs ending with .localhost. You can see an in depth explanation of the issue here and here.

The solution is either to use a different browser (but no doubt other browser will also implement this measure at some point), or to simply change your domain names. I have changed everything from .localhost to .local and everything works as normal.

6 comments

  1. Try this also:

    Chrome > Preferences > Clear Browser History > The beginning of time / whenever > tick only CACHED IMAGES AND FILES, then Clear your browsing history

    I’ve had this issue a few times using `.dev`

    1. I had to do this for a similar issue in Grails. Clearing the cache allowed me to just refresh the page and the error was gone. Thanks!

Leave a Reply

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