Home > DevOps > Unsecure http requests to localhost automatically redirect to https

Unsecure http requests to localhost automatically redirect to https

After being annoyed from having to deal with this for a few days, I thought I’d put it out there so if you experience it, you won’t get as annoyed as I did.

I was trying to go to http://localhost:4200 when developing an Angular app and Microsoft Edge (Google Chrome in disguise) kept changing the URL from http://localhost:4200 to https://localhost:4200 when entering the address directly in the browser.

Because of a previous project which ran on localhost was configured to send an HSTS header, requests to localhost were upgraded from http to https.

You’ll have to go into the advanced settings for Google Chrome or Microsoft Edge to remove any sites which the browser has a stored HSTS policy. Depending on which browser you’re using, it’s either

  • chrome://net-internals/#hsts
  • edge://net-internals/#hsts

Regardless, the page is the same in both browsers.

A screenshot of where you can delete the policy for a domain that has an HSTS policy  associated with it

After that, you should be good to go so relaunch the browser.