google-chromelocalhost

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


Solution

  • 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