9

This question is not a duplicate because the suggested duplicate does not solve this problem. There is no such flag on chrome://flags/.

I'm using the Google Chrome web browser and WampServer to locally host a website. When I try to see my website on the localhost address in Chrome I'm getting the error ERR_CONNECTION_REFUSED. When I type the IP address 127.0.0.1 instead, the result stays the same.

On the other hand, if I enter localhost into the address bar on Internet Explorer I'm getting the expected result: The webpage displayed.

How do I make Chrome's localhost work? It may be some sort of security measure but to me it's rather an annoyance than anything else.

BullyWiiPlaza
  • 558
  • 2
  • 9
  • 23
  • 1
    What happens when you type `http://127.0.0.1/` on both, and when you type `http://[::1]/` on both? – u1686_grawity Aug 23 '15 at 13:54
  • @grawity Yes, both surprisingly work in `Chrome` and also on `Internet Explorer`. It seems like Chrome tries to do `https://localhost/` but can't because a secure connection is not available. – BullyWiiPlaza Aug 23 '15 at 13:56
  • 3
    possible duplicate of [Google Chrome can't access localhost domains](http://superuser.com/questions/646304/google-chrome-cant-access-localhost-domains) – RiggsFolly Aug 24 '15 at 22:48
  • 2
    @RiggsFolly The given solution does not solve the problem though – BullyWiiPlaza Aug 25 '15 at 11:56
  • Google for `Chrome and localhost` Chrome has a few odd issues with localhost for some unknown reason. There are a few possible solutions, depending on your version and how many times the issue has been fixed and then re-occured. – RiggsFolly Aug 25 '15 at 12:05
  • Just create a new alias in your hosts file as to avoid the name altogether>? – Jay Aug 25 '15 at 12:09
  • @BullyWiiPlaza Please edit your question to clearly indicate you've tried the solution at the proposed duplicate question and that it did not work. Your question will be marked duplicate if you don't explain why the answer at the proposed duplicate doesn't work. – I say Reinstate Monica Aug 29 '15 at 01:32
  • You wouldn't happen to have the HTTPS Everywhere plugin installed on Chrome, do you? It attempts to HURL all domain addresses to HTTPS, but because IP addresses can't easily be bound to domain certs, it won't try it with IP's. If this is installed, try disabling it for *.localhost and post what happens. – George Erhard Apr 28 '17 at 20:05

2 Answers2

0

For me, it usually worked after a reboot .. or several, but finally took some time to look up the possible reasons. These are what I encountered - using Mac OSX.

1) Domain name - localhost is common and a must working name, I personally used .dev domains until it became a top-level domain with forced https If you're using a local domain, make sure the DNS is pointing to the localhost address (127.0.0.1). You can open a terminal and run:

ping mydomain.unnamed If not working then check your hosts file.

2) Apache syntax errors - Run httpd -t to check syntax, also make sure you do have the domain showing up in vhosts httpd -t -D DUMP_VHOSTS

3) Apache port 80 or 443 blocked - Either by firewall or other applications, so check ports:

lsof -i:80 with kill -9 (lsof -ti:80),also restart the apache service.

4) Invalid SSL certificate - For https localhost domains, renew certificates or re-add them to the Keychain.

5) Less common - Chrome extension that controls networking and probably forgotten about setting it, disable it and test.

ion
  • 101
  • 2
-1

Open command prompt as Administrator and type these two commands one by one:

netsh advfirewall firewall add rule name="TCP Port 80" dir=in action=allow protocol=TCP localport=80
netsh advfirewall firewall add rule name="TCP Port 80" dir=out action=allow protocol=TCP localport=80

After doing so, restart the Wamp server and try to access http://localhost. If that fails, try one of these links:

  • http://127.0.0.1:80
  • http://127.0.0.1:8080
  • http://127.0.0.1:443
  • http://127.0.0.1:4443

Good luck!

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212