Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localhost not working in Chrome, 127.0.0.1 does work

I'm trying to run a local node server, but for whatever reason localhost:3000 does not work. The error page states This webpage is not available ERR_CONNECTION_CLOSED However, 127.0.0.1:3000 does work. I have tried making changes to my hosts file, but to no avail. Does anyone have any idea what's causing the problem?

Chrome version is 46.0.2490.80 m

like image 531
Matt Avatar asked Nov 04 '15 14:11

Matt


People also ask

Why localhost is not opening in Chrome?

Go to chrome://flags and set "Built-in Asynchronous DNS" to "Disabled", then restart the browser. This allows all local domains to be accessed. Looks like DNS was just choking up the issue.

How do I enable localhost in Chrome?

1) Open Google Chrome browser. 2) Type chrome://flags/#allow-insecure-localhost in address bar. 3) Click on Enable. 4) Select "Relaunch Now" option displaying at the bottom after making the changes OR Re-open the chrome browser.

Why is my localhost not working?

What Is the Localhost Refused to Connect Error? The localhost simulates a web server running on your computer. When the “localhost refused to connect” error appears, it is likely due to misconfigured port. Other common reasons include insufficient permissions and the Apache webserver not running properly.


2 Answers

Here are the steps I took to make this work correctly:

  1. Edited my hosts file so 127.0.0.1 localhost. was present, and saved the file
  2. Cleared my Chrome cache, specifically cookies and cached files
  3. Cleared host cache in chrome://net-internals/#dns
  4. Restarted chrome

Alternatively, this also works:

  1. Navigate to chrome://net-internals/#hsts
  2. Under "Delete domain", type localhost and delete

Unbeknownst to me, my project had an HSTS middleware that set an HSTS cookie

like image 178
Matt Avatar answered Sep 20 '22 21:09

Matt


For me (I had HTTP and HTTPs dev server on same port)

  • Chrome Dev tools F12
  • Application tab
  • Clear storage sub-tab
  • "Clear site data" button
like image 44
bedla.czech Avatar answered Sep 19 '22 21:09

bedla.czech