15

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

4 Answers 4

27

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.

5
  • Awesome answer. I was rummaging through every single apache configuration file thinking something was wrong. Didn't even think to try to access in firefox but when I did it worked and was even more confused. This worked for me instantly. Jun 10, 2015 at 16:55
  • 1
    Very important about .dev e.g. mylocalsite.dev. As soon as I changed everything to mylocalsite.local, it works.
    – mummybot
    Mar 16, 2016 at 11:46
  • 1
    Tried your suggestion on Windows but unfortunately didn't work :(
    – Brett
    May 10, 2016 at 9:10
  • I was having .dev in the suffix. Changed it to something else and it worked on on chrome and chromium based browser
    – Irfan Raza
    Mar 4, 2018 at 6:51
  • For me it was also the move from mysite.dev to mysite.local ... not sure why it works that way though
    – villageek
    May 18, 2021 at 17:43
8

Here is how to fix xampp virtual hosts in chrome and firefox that are ending with .dev. who doesn't work anymore (in most versions of chrome, since .dev is real domain registered and reserved from google - [Dev domain ICANN]).

I had so much trouble, with getting virtual hosts working properly on both firefox and chrome, but at the end i find out that the best solution is to make two different hosts for each local domain. So i ended up with something like: Here is hosts file in (C:\Windows\System32\drivers\etc\hosts):

This is needed, becouse if you still want your localhost alive

127.0.0.1 localhost.
::1 localhost.
fe80::1%lo0  localhost.

This works fine in Firefox.

127.0.0.1 laravel.dev
::1 laravel.dev
fe80::1%lo0 laravel.dev

This works perfectly on Chrome.

127.0.0.1 laravel.localhost
::1 laravel.localhost
fe80::1%lo0 laravel.localhost

And here is my xampp httpd-vhosts.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "D:/xampp/htdocs/"
    ServerName localhost
    ServerAlias localhost
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@laravel
    DocumentRoot "D:/xampp/htdocs/laravel/public/"
    ServerName laravel.dev
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@laravel
    DocumentRoot "D:/xampp/htdocs/laravel/public/"
    ServerName laravel.localhost
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@testsite
    DocumentRoot "D:/xampp/htdocs/testsite/"
    ServerName testsite.dev
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@testsite
    DocumentRoot "D:/xampp/htdocs/testsite/"
    ServerName testsite.localhost
</VirtualHost>

I hope this helps for someone, because i lost a couple hours, finding out the best solution, and make the things work. :)

tags - virtual host doesn't work on chrome.

3
  • Could you explain what these two lines do? ::1 laravel.localhost fe80::1%lo0 laravel.localhost. Thanks!
    – Brett
    May 10, 2016 at 9:12
  • Yes @Brett. The first one ::1 is a shortened notation of IPv6 loopback address - equivalent of IPv4 loopback 127.0.0.1. And the second line fe80::1%lo0 laravel.localhost is IPv6 equivalent of 127.0.0.1. This %lo0 might be different, depending on your local adresses and interfaces. It's an IPv6 address. The fe80:: block is reserved for link-local addresses. Link local addresses are used for packets sent only to directly connected devices (not routed). The network discovery protocol (NDP) is the biggest user of link-local addresses (NDP sorta replaces ARP and DHCP in IPv6). May 14, 2016 at 10:32
  • tags - virtual host doesn't work on chrome. what does it mean i have done changes but its still not working for chrome wheras it works for firefox
    – sunil
    May 3, 2018 at 6:17
2

Another option is to replace in your file /etc/hosts any entry defined as your_domain.localhost with something like local.your_domain. But this would also require you to change the "ServerName" and "ServerAlias" value in your virtual hosts files.

-1

For me is working this:

In hosts:

127.0.0.1 localhost.
::1 localhost.
fe80::1%lo0  localhost.

And In httpd.conf:

<VirtualHost localhost>
  DocumentRoot "D:/Apache/htdocs/projects/some-project-root"
  ServerName some-project.localhost
</VirtualHost>

Important is write to VirtualHost tag "localhost", "127.0.0.1" does not works in chrome.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.