47

There is a similar question about the same issue on Chrome, with an answer that solves it in Chrome.

When I try to go to http://localhost:8000/, Firefox redirects me to https://localhost/ . Why? If I open an incognito window, this doesn't happen. I can't continue developing until I solve this. Please help.

Alejandro Veintimilla
  • 10,743
  • 23
  • 91
  • 180

9 Answers9

51

This happened to me after I worked on a site that used https and then tried switching back to one that does not.

Unfortunately, the accepted answer did not work for me. What I needed to do was:

  1. Open the Firefox History (ctrl+h)
  2. Find the page (127.0.0.1:3000, in my case)
  3. Right-click it and choose the last option: "Forget About This Site"

If you use localhost - with our without port - to access your page, then you will notice that localhost does not show up in your history. This makes it impossible to access the "Forget About This Site" option.

Fear not! You can work around that issue.

  1. Visit your site using 127.0.0.1 instead of localhost. So, for example, localhost:3000 becomes 127.0.0.1:3000.
  2. Now open the Firefox History (ctrl+h)
  3. Find the page (127.0.0.1), right-click, and "Forget About This Site"
  4. Now, access localhost and you will find that it works again. This is because forgetting about 127.0.0.1 cleared data for both 127.0.0.1 as well as for localhost.
Finn
  • 1,510
  • 13
  • 22
32

So, here is my experience. I had the same issue.

At first : try in private mode. If you dont have the problem, do this :

When you open a new tab, you have to go to the Firefox configuration ("about:config") you check "I'll be careful I promise". Then in the search field you type autofill, you have to set browser.urlbar.autofill to false and if it still doesn't work you can delete the history, it should fix it. It worked for me.

I think the problem comes from the fact that I opened once localhost in https so the browser wants to do it every time.

  • None of those worked for me (I have the problem not with localhost/ but with a domain, that I redirected to localhost in my /etc/hosts/ file) It seems to be a hsts problem, cause I could solve it in Chrome like this: https://stackoverflow.com/a/28586593/1069083 – rubo77 Apr 30 '19 at 09:20
  • 1
    It worked for me after I set it to false and deleted the history also. My problem was the redirect from localhost:8080/ to localhost:8080/auth/. – Elio Jul 31 '19 at 19:01
13

I'm running MAMP on OSX with default ports (http://localhost) and what worked for me was changing this preference to false on about:config:

browser.fixup.fallback-to-https

I tried clearing History, Site Preferences, changing browser.urlbar.autofill and network.stricttransportsecurity.preloadlist, disabling all extensions, but none of these worked.

brasofilo
  • 25,496
  • 15
  • 91
  • 179
4

In their last update, Chrome and Firefox browsers now redirect all domains with the pattern *.dev and *.foo to https. I found a solution for Firefox but, haven't yet found a solution for Chrome.

for Firefox

Visit the address about:config
Search for the parameter network.stricttransportsecurity.preloadlist and change it's value to false

Since this question refers to a localhost, alternative solutions involve:

  • Change your URLs and use new domains .
  • Modify the hosts file, If you point on IP addresses or virtual hosts, you can modify your hosts file to use local domains
  • Or, Use SSL, you can choose to activate SSL on your web server.

Source: https://tutoref.com/how-to-prevent-firefox-and-chrome-from-forcing-dev-and-foo-domains-to-use-https/

rwilson
  • 159
  • 2
  • I tried this, but it had no effect. it still redirects my test-domain foo.example.com to https://foo.example.com – maybe because the domain really exists, and I just redirected it to localhost in my hosts file? – rubo77 Apr 30 '19 at 09:16
  • This fixed my issue. I was using .home domain for my self-hosted servers ,so it isn't limited to only the .dev domain. – majorgear Feb 14 '21 at 03:24
4

The solution that worked for me:

  1. Go to about:config
  2. Look for network.stricttransportsecurity.preloadlist and set it to "false"
  3. Enjoy
Reza Shek
  • 581
  • 1
  • 8
  • 18
1

To connect to a Pluto.jl instance, the only workaround so far was to launch in a private window:

firefox -new-instance -P Pluto --private-window http://localhost:1237

Finns answer fixed it once, but subsequent calls timed out.

Comments left in a relevant bug report.

ederag
  • 2,409
  • 25
  • 49
1

In my case, the issue was fixed by restarting the Apache web server.

Haris ur Rehman
  • 2,593
  • 30
  • 41
0

enter image description here

What ended up working for me was toggling Enhanced Tracking Protection to OFF via the shield icon in the address bar. I did this for both localhost and the site that it was redirecting to. Hope this helps someone.

chening
  • 11
  • 2
0

I tried the top answer and deleting individual history didn't do the trick for me. I tried deleting history from localhost, 127.0.0.1, and 0.0.0.0, but still saw the issue. When I cleared all of my history, the issue went away.

lobati
  • 9,284
  • 5
  • 40
  • 61