Google Chrome virtual hosts not working with ERR_NAME_NOT_RESOLVED error after update

Tariq Khan picture Tariq Khan · May 27, 2015 · Viewed 23k times · Source

I started getting this error for all my local virtual hosts on apache in the morning when I updated my Chrome to the latest version on ubuntu.

While all of them work on other browsers chrome started misbehaving with ERR_NAME_NOT_RESOLVED error.

Screen shot for the error

Answer

Tariq Khan picture Tariq Khan · May 27, 2015

Got it fixed like this:

Clear up the Chrome's DNS cache by typing this in the Chrome browser

  • chrome://net-internals/#dns

Screenshot -> Flushing Chrome DNS cache

  • You will see a button "Clear Host Cache". Press that DNS cache will be flushed.

  • Keep this DNS window open. Now access the virtual host in the browser for me it was http:/api.localhost. Once you do that you will see a new entry in the DNS window. for me it was "localhost." notice the period "." at the end of localhost that showed an error.

  • Last step is to simply add this entry as

    127.0.0.1 localhost.

    in the hosts file located at for ubuntu : /etc/hosts

    for windows : C:\Windows\System32\drivers\etc\hosts

Another solution could be to ditch the .localhost /.dev at the end of your local virtual host domain

This has to do with some new changes by google. ".dev" and ".local" comes under google's TLD (In the corner of the internet where people care about DNS, there is a bit of an uproar at Google's application for over a hundred new top-level domains, including .dev etc)

Use a domain name you own. Possibly using the full name like "localhost.dev.$yourdomain" could help here on the setup.