58

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

Matt
  • 1,707
  • 1
  • 16
  • 18
  • This solution worked for me here: https://superuser.com/a/1423344/644358 – MotsManish Apr 09 '19 at 14:06
  • Old post but I found the [answer here](https://superuser.com/questions/1159862/when-why-would-chrome-get-500-error-on-localhost-but-load-ok-from-127-0-0-1-whi). It explains everything. – K. Pham Jul 09 '19 at 09:06

11 Answers11

64

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

Matt
  • 1,707
  • 1
  • 16
  • 18
  • Was searching so long and had no idea what I did to cause this. For anyone coming in from Google, this happened to be by using react-aad-msal package and running a killall command on it when it froze while loading. This fixed it for me completely. – GoreDefex Apr 01 '20 at 12:38
  • The alternative solution works for me – Arba Aug 10 '22 at 07:37
  • Alternative solution also works here – NomadMonad Jan 28 '23 at 12:37
15

I ran into a similar issue on my MacBook but none of the existing answers worked. I even tried the nuclear option and did a factory reset on my computer.

The issue turned out to be coming from the AirPlay receiver listening on Ports 5000 and 7000, which was creating the 403 error when I tried to serve something at localhost:5000.

The solution, as detailed here, was to uncheck AirPlay Receiver in System Preferences > Sharing

tgordon18
  • 1,562
  • 1
  • 19
  • 31
9

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
bedla.czech
  • 879
  • 1
  • 8
  • 13
7

I solved my problem by:

  • opening the developer console F12
  • Going to network tab
  • Check Disable Cache
  • Browse locahost
Jeff
  • 979
  • 3
  • 10
  • 18
5

What you can do is go to Chrome setting > Privacy and Settings > See all the cookies and site data, search for localhost and delete it. Then refresh your site it will be working.

Regards

Deepak Rai
  • 2,163
  • 3
  • 21
  • 36
user15294988
  • 51
  • 1
  • 1
3

if you're using a proxy there's a checkbox to bypass it for local addresses.

3

follow these steps.

  1. open chrome
  2. go to setting
  3. Privacy and security
  4. Clear browsing data
  5. check cookies and other site data
  6. click clear data.
Dilan
  • 2,610
  • 7
  • 23
  • 33
2

I had same issue and I cleared cookies and cache and it worked

enter image description here

code
  • 73
  • 5
0

Go to Setting/clearBrowserData and just check all of history, cookies and cached files.

ParisaN
  • 1,816
  • 2
  • 23
  • 55
0

For me, Browse in Private (Ctrl + Shift + N) was enough.

jMarcel
  • 958
  • 5
  • 24
  • 54
-1

Finally I have solved this problem

  1. For those who have tried the clearing the cache from the browser and still facing the same issue follow these steps
  2. search for live server(ctrl+shift+x) you will find a settings icon. click on Extension settings
  3. you can find Live server>Settings:Chrome Debugging Attachment click on edit in Settings.json
  4. just add this (if there are multiple lines make sure to add comma[,]) "liveServer.settings.port": 0
  5. Doing This It will randomly pick an opened port each time.