For a while I have been running two different server environments on my Windows 7 OS. IIS runs on 127.0.0.1 and I have a Vagrant VM that uses 192.168.33.10. My hosts file looks something like:
vagrantsite1.localhost 192.168.33.10
vagrantsite2.localhost 192.168.33.10
iissite1.localhost 127.0.0.1
iissite2.localhost 127.0.0.1
Up until a week or so back, this setup worked perfectly fine, however something has changed recently with my Chrome browser. Now all of a sudden in Chrome when I access vagrantsite1.localhost it is referencing the IIS 127.0.0.1 IP address instead of 192.168.33.10. I checked this using chrome://net-internals/#dns and even cleared the host cache, which did not seem to resolve anything.
After some research I have found if I add localhost 192.168.33.10 to my hosts file, the vagrant sites work, however now my IIS sites try to access this IP instead of 127.0.0.1. It seems that Chrome does not let me use a different IP for somesite.localhost from localhost entry. This is not a problem in IE and Firefox, and up until recently it was not a problem in Chrome.
I was wondering if anyone else has this problem or a potential solution (rather than manually setting localhost IP each time I want to switch servers)? I realize I can use a different port number for one of the servers as a solution, however since everything works fine in IE and Firefox, and until recently worked fine in Chrome, I would like to know the cause.
This is a "feature" that was just added to chrome, all localhost domains will always resolve to loopback.
See the following links for more information:
https://code.google.com/p/chromium/issues/detail?id=455825
https://codereview.chromium.org/938093003
One workaround is to change your entries to not end in localhost, something like "vagrantsite1.local 192.168.33.10" instead should work.
Related
I answered this below for anyone that is interested
I'm on Windows 10 using Chrome, Firefox and MS Edge. I'm trying to do something for a class I'm taking and can't get it to work. All I want to do is add something like this to the hosts file:
127.0.0.1 mysite.dev
This is ALL to run on my local PC. I eventually need to have my site able to run on IIS, but this is the first step and I can't get past it. (I'm on my second day trying)
What I've done:
I did edits in notepad on a file on my desktop.
I renamed the original hosts file in the drivers/etc directory.
I copied my file into the drivers/etc directory.
I ran ipconfig -flushdns
I successfully pinged the new site with: ping mysite.dev
I cleared browsing history in all three browsers.
I reopened all three browsers.
All that failed to make any difference (and I rebooted as well) So I added this:
I ran ipconfig -flushdns
Then ipconfig -renew
Then ipconfig -registerdns
Then repeated steps 5->6 and all failed to make any difference. These are the errors per browser:
Chrome: This site can’t be reached mysite.dev refused to connect.
Firefox: Unable to connect Firefox can’t establish a connection to the server at www.mysite.dev.
MS Edge: Hmmm...can’t reach this page
I noticed that all three browsers changed http to https. Not sure if that mattered but I followed instructions to disable this re-direct for all three browsers and NONE of them actually stopped the redirect to https.
And I still can't the correct result, which should be the IIS default page. I can see the IIS default page with localhost, so IIS is running.
Help! Any ideas or directions at all would be very appreciated!
Got the answer from someone. Google owns the .dev domains and has restrictions on it so it HAS to be HTTPS, which requires certs etc, which is not in the scope of my class. I just changed it to mysite.local and BOOM!, there it was! Thanks.
In the past, It was always enough for me to start local development server on address localhost, running on port 8008 - Therefore in browser I could access my development server just by entering localhost:8008 into browser's address bar.
My Goal
I must start my local dev server under the address mysite, port 8008. No exceptions.
What I Tried
In order to do this, I added mysite into my /etc/host file like follows:
127.0.0.1 localhost mysite
Problem
Upon entering mysite:8008 into address bar of every browser I tried (Safari, Firefox) was my dev site is correctly displayed. However I cant get it work on Google Chrome. This is what Google Chrome displays upon entering mysite:8008 into address bar:
This site can’t be reached mysite refused to connect.
Search Google for mysite 8000
ERR_CONNECTION_REFUSED
However localhost:8008 works displays my website correctly. Any ideas?
It is totally wierd, but for some mysterious reason it looks like Chrome cares for ordering in the /etc/hosts file. Problem has been solved by switching order in localhost line of /etc/hosts file to following:
127.0.0.1 mysite localhost
When I attempt to visit http://mysubdomain.localhost chrome resolves to [::1]80, even if there is an explicit entry for this domain in the hosts file. No other browser behaves this way. Firefox, safari, and curl all resolve the IP address given in my hosts file. This is the entirety of my hosts file at the moment:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
192.168.88.88 mysubdomain.localhost
And yet, when I attempt to visit http://mysubdomain.localhost in chrome, it does not resolve to 192.168.88.88. This is problematic for me, because 192.168.88.88 is a virtual machine running on my computer. I could change the domain to http://mysubdomain.local or http://mysubdomain.dev, but that would require me to update a configuration file used by many people on the project, which I'd rather avoid, because I may break some aspect of their workflow.
Firefox (working as desired)
curl (working as desired)
Chrome (not working as desired)
Some things I've already tried:
I am not using a proxy
I have cleared browser cache many times
I have cleared dns cache from chrome://net-internals/#dns
I have restarted the machine several times
I have cleared the system DNS cache with the terminal command sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder
I have tried incognito mode several times
I have tried created a new chrome user account
System information:
Chrome version: 53.0.2785.116
OS Version: Mac OS 10.11.6 (El Capitan)
Upon further review, I think this is unfortunately working as designed. From the chromium issue queue:
This was done as a security mitigation, as OS X's resolver does not properly ensure that .localhost domains are not queried on the network, which is a key security property of ensuring .localhost is truely local. Because we can't trust the resolver to do the secure thing, we unfortunately can't trust the resolver (even when it may be secure)...
The security risk is not about properly configured server vs improperly configured server. It's that a DNS resolver should never send foo.localhost requests out to the network. If it does, a network attacker could make "foo.localhost" point to any IP of their choosing. This is bad, because "localhost" (and "*.localhost") have special privileges (c.f. http://www.w3.org/TR/powerful-features/#is-origin-trustworthy ), and because they have those special privileges, they need to be secure.
In fact, it seems that chrome may be the only tool in the bunch properly implementing RFC-6761 which states in part:
Name resolution APIs and libraries SHOULD recognize localhost
names as special and SHOULD always return the IP loopback address
for address queries and negative responses for all other query
types. Name resolution APIs SHOULD NOT send queries for
localhost names to their configured caching DNS server(s).
So it seems there is no way to fix this. I will change the domain of my virtual machine to http://mysubdomain.local
After playing around with this and using firefox for a while, I found a workaround by accident. Instead of changing your development environments you can simply install https://www.telerik.com/download/fiddler.
Fiddler bypasses the DNS of chrome, I believe, so you are left with a perfectly working system without having to change all your environments.
I have tested this on Windows 10 with Hyper-v over vagrant.
I have a local webdev setup using AMPPS on OSX. I've done most of my work on Firefox and that's been working fine, but trying it on Chrome today gave me a whole bunch of Failed to load resource: net::ERR_CONNECTION_CLOSED errors everywhere. Looking further it seems like Chrome wants to access every resource through HTTPS. Firefox doesn't have this issue, it access all resources through HTTP and the site displays fine.
Is there any way to force Chrome to access localhost through regular HTTP? I've tried every solution I could find - including going to chrome://net-internals/#hsts and deleting localhost (localhost doesn't show up in the domain query so there's nothing to delete) - and nothing seems to work.
I have defined some virtual servers that until the last days were working fine.
Now they don't on Chrome, but there are no problems in firefox or safary.
I get this:
This webpage is not available
ERR_ICANN_NAME_COLLISION
Hide details
This site is using a new generic top-level domain (gTLD). If you have
used loc.dev to access an internal site in the past, contact your
network administrator.
I found as a solution:
Set the "Built-in Asynchronous DNS" to "Disabled" in chrome://flags, but the is no such flag in my chrome version ( 43.0.2357.81 )
Do you know a solution for this?
LE : If i move the site on the htdocs file and i go on the url http://localhost, it works. It seems that it has a problem only with virtualhosts.
Got the same issue after updating to the latest chrome version last night. I was getting a ERR_NAME_NOT_RESOLVED error only on google chrome for all of my virtual hosts. Here's how that looked.
Screen Shot-> DNS name not resolved error
Here's the fix I made.
Clear up the google 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 to your localhost file.
Your hosts file should be updated with an entry to resolve localhost. to 127.0.0.1:
# dont forget the trailing . !!!
127.0.0.1 localhost.
in the hosts file located at:
for linux : /etc/hosts
for windows : C:\Windows\System32\drivers\etc\hosts
Another solution for your case might be to ditch the .dev at the end of your local virtual host domain
This has to do with some new changes by google. ".dev" 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)
Try this Use a domain name you own. Possibly using the full name like "localhost.dev.$yourdomain" could help you here depending on your setup.
With the 'chrome' I face the same issue because by mistake I comment out the
127.0.0.1 localhost from the host file, But 'Firefox' will work.
Just make sure your host file include
127.0.0.1 localhost
FIXING
Try contacting your system administrator.
ERR_ICANN_NAME_COLLISION.
if you are using magento and getting such error
just go to you database and search for core_config_data
click on it then check your web store name
change the store name
restart your wamp and fixed.
Worked for me:
chrome://net-internals/#hsts -> Domain Security Policy -> Delete domain security policies -> enter there localhost and press delete
Here is another catch for you, my virtual hosts in Windows hosts file were defined as:
127.0.0.1 bla.bla.bla.localhost
127.0.0.1 bla2.bla2.localhost
And actual server virtual host directives in Xamp Apache Vhosts file made it all work nicely in all browsers, but Chrome!
A simple fix - dont end with full "locahost" word, rename the vhosts to end with anything else, just "loc" did it in my case, all works in Chrome now!
Been having this problem with Version 56.0.2924.87 (64-bit) of chrome, attempting to access a vm by gset.localhost, just would not work.
Changed the url in the hosts file to gset.loc and it works fine.
The answer seems to be do not use localhost in your hosts file urls when attempting to access a virtual machine running on your machine using chrome.
All browsers - chrome, firefox, safari were not resolving my virtual host and kept re-directing to www.mysite.dev
After pulling my hair for hours - it turned out I just need to change mysite.dev to www.mysite.dev in the /etc/hosts file.