Set address in /etc/hosts for local php development in Google Chrome - google-chrome

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

Related

Adding 127.0.0.1 to hosts file to redirect locally has error. Says my site “refused to connect.”

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.

Chrome insists on accessing localhost through HTTPS, any way to change that?

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.

Chrome now treating IP address of localhost same as somesite.localhost

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.

Chrome localhost does not 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.

Chrome & Firefox keep asking for authentication when going to localhost

I'm having a problem where Chrome & Firefox have both started bringing up a popup window saying authentication required when going to localhost (401 page).
If I am on the network I can put in my usual network username/password and it works fine, but if I'm offline (the very reason I'm using localhost) that authentication fails and I get sent to a 403 page.
This does not happen in IE and was not happening a few days ago, my network settings are set to ignore Proxy on localhost and auto detect settings is switched off.
Any ideas?
Problem is the permission of your site directory. If you put the folder under your home (~), then this problem will probably occurs. Try to give your home folder a wider permission. Especially read permission for Others.
sure, if you browse the localhost pure directory you need apache / server authentication
Check your server authentication credentials (user and pass) and this is normal!
while if you browse localhost/mysite you will need not an auth ;)
also be sure your localhost/myproject folder has 755 chmod permissions
finally check if in your localhost/myapp/ there is a .htpasswd file and post it here
I also encountered a similar problem and reinstalling chrome to older version, changing proxy setting didn't help.
I have started using other browsers, however i use the below workaround in case I need to work in chrome.
1.) Click on login without inserting any username and password .
2.) Click on (X) to close the window.
The window would disappear. However, it will reappear if you open any other site or window.