Localhost not working in Chrome, 127.0.0.1 does work

醉酒当歌 提交于 2019-12-28 11:54:04

问题


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


回答1:


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




回答2:


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



回答3:


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




回答4:


I solved my problem by:

  • opening the developer console F12
  • Going to network tab
  • Check Disable Cache
  • Browse locahost


来源:https://stackoverflow.com/questions/33524826/localhost-not-working-in-chrome-127-0-0-1-does-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!