3
votes

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.

1
What IP shows when you ping vagrantsite1.localhost? If it show 127.0.0.1 it might be a mis-configurationLuc
When I ping vagrantsite1.localhost I get 192.168.33.10. When I look in Chrome at chrome://net-internals/#dns after I clear host cache and visit vagrantsite1.localhost, I see new entry for localhost 127.0.0.1. It's as if Chrome is getting confused thinking that vagrantsite1.localhost = localhost, which is not the case. As mentioned this only happens in Chrome, Firefox and IE appear to be resolving the correct IP.Ian Carnaghan

1 Answers

4
votes

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:

One workaround is to change your entries to not end in localhost, something like "vagrantsite1.local 192.168.33.10" instead should work.