4

What is happening

I have a simple Apache server set up on my machine, accessible via localhost on port 80. When accessing the following addresses :

It does work on Chrome/Firefox and other browsers

ping/curl to localhost works and returns a 200 response.

After adding an entry to my hosts file, to point a host name to localhost, it seems Chrome is not honoring the entries in the hosts file.

Let me explain, my hosts file looks like this now :

# localhost name resolution is handled within DNS itself.
# 127.0.0.1       localhost
# ::1 localhost

::1 mydomain.local

When accessing the host name mydomain.local with Firefox/Edge/Other browsers it returns the default page of my Apache server as a 200 response.
ping/curl to mydomain.local checks out successfully and shows it is actually pointing to localhost at the ::1 ipv6 version of localhost.

Yet somehow, Chrome throws an DNS_PROBE_FINISHED_NXDOMAIN error on that host name.

What has been tried

  • Fresh Chrome install
  • Flushing Windows DNS cache with ipconfig
  • Flushing Chrome DNS cache through chrome://net-internals/
  • Disabling all DNS prefetching and protection settings (I just went through and disabled everything on Chrome https://imgur.com/a/okB3ofG)
  • Running Chrome with the following flags
    • --dns-prefetch-disable
    • --disable-preconnect
    • --incognito
    • --start-maximized
    • --disable-async-dns

All attempts unsuccessful

System setup

  • Windows 10 Pro x64 (1809)
  • Chrome Version 74.0
  • Firefox Quantum 66.0.3

--
Edit I know that Chrome doesn't play well with some TLDs, I have tried different options, like .loc .test .localhost without success

--
Edit 2
The referenced possible duplicate is 3 years old, and doesn't provide a solution. If there's no solution for this issue, is this behavior documented from Chromium ? That it doesn't allow hosts entries ?

  • Possible duplicate of Chromium not checking hosts file – Ramhound Apr 25 '19 at 11:18
  • Why did you remove default 127.0.0.1 localhost from your hosts file? The duplicate is still accurate, Chrome doesn’t support the IPv6 address your using. Add 127.0.0.1 mydomain.local to the hosts file and it should work after a DNS flush. – Ramhound Apr 25 '19 at 11:27
  • I have not removed the entry you mentioned, that line is commented by default. Chrome does support IPv6 since it loads my Apache server at http://[::1]/ To your edit: That has already been tried and mentioned above in the post, still unsuccessful – Rezrazi Apr 25 '19 at 11:33
  • It’s way to early, some reason, I remember those lines being not commented. I can’t find a similar question that was asked recently, if ended up being the TLD, they changed it and it suddenly worked. However, your hosts file doesn’t mention trying the 127.0.0.1 entry. – Ramhound Apr 25 '19 at 11:37
  • Possible duplicate of: superuser.com/questions/648133/… – Ramhound Apr 25 '19 at 11:47
1

I figured out how to "fix" that, posting it here for future readers.

How did I fix it ?

How did I get Chrome to actually point a host name to localhost ? Actually it's some funky behavior here. Simply by changing the TLD I'm using to .localhost
From Chromium's guidelines, and since the introduction of .dev as a legit TLD, there are some reserved TLDs.

To safely satisfy these needs, four domain names are reserved as listed and described below.
- .test
- .example
- .invalid
- .localhost

".test" is recommended for use in testing of current or new DNS related code.
".example" is recommended for use in documentation or as examples.
".invalid" is intended for use in online construction of domain names that are sure to be invalid and which it is obvious at a glance are invalid.
The ".localhost" TLD has traditionally been statically defined in host DNS implementations as having an A record pointing to the loop back IP address and is reserved for such use. Any other use would conflict with widely deployed code which assumes this use.

Read more here

Yet Chrome didn't point to localhost when I tried using .test it is just ... weird, it should've worked. If anyone has any input on this, please be my guest.
Beware Although this solution worked on my system, it is believed to cause some unexpected behavior on OSX systems.

As of this answer, on Chrome 74, it not possible to disable Chrome's own DNS host resolver, and aside those TLDs, all hosts entries will be ignored

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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