Ce site disposera de fonctionnalités limitées pendant que nous effectuons des opérations de maintenance en vue de vous proposer un meilleur service. Si un article ne règle pas votre problème et que vous souhaitez poser une question, notre communauté d’assistance est prête à vous répondre via @FirefoxSupport sur Twitter, et /r/firefox sur Reddit.

Rechercher dans l’assistance

Évitez les escroqueries à l’assistance. Nous ne vous demanderons jamais d’appeler ou d’envoyer un SMS à un numéro de téléphone ou de partager des informations personnelles. Veuillez signaler toute activité suspecte en utilisant l’option « Signaler un abus ».

En savoir plus

Firefox loads wrong port on localhost unless hard refreshed

  • 8 réponses
  • 1 a ce problème
  • 2 vues
  • Dernière réponse par natemara

more options

When running multiple web servers on my computer, Firefox does not behave correctly when navigating between them.

Service 1: port 8080 Service 2: port 9090

For illustration purposes, I created a simple server that just sends back the port and URL path that you requested in the form:

Hello, you've hit 8080/foo/bar

If you request http://localhost:8080/foo/bar for example.

Here's what happens:

1. Navigate to localhost:8080/foo - browser displays "Hello, you've hit 8080/foo" - this makes sense

2. Navigate to localhost:9090/foo in the same tab - browser displays "Hello, you've hit 8080/foo" - this does not make sense since I've changed the port

3. Navigate to localhost:9090/foo/bar - browser displays "Hello, you've hit 8080/foo/bar" - this really does not make sense since I've changed the port and the path

4. Hard refresh (Ctrl-Shift-R) - browser displays "Hello, you've hit 9090/foo/bar"

I've tried this with a brand new install of the latest FF, running in safe mode, and the issue is still present. I don't know what is causing this issue, but as a web developer that frequently runs multiple local servers, it's infuriating. The servers on the different ports don't need to be in the same tab to mess with each other either. I've tried this with Chrome on the same computer, and it works perfectly, so it's not a problem with the network stack on my laptop.

Has anyone else experienced something like this?

EDIT: I noticed that when I use separate container tabs, this issue goes away. This helps a little, but I still have use cases where this does not help.

When running multiple web servers on my computer, Firefox does not behave correctly when navigating between them. Service 1: port 8080 Service 2: port 9090 For illustration purposes, I created a simple server that just sends back the port and URL path that you requested in the form: Hello, you've hit 8080/foo/bar If you request http://localhost:8080/foo/bar for example. Here's what happens: 1. Navigate to localhost:8080/foo - browser displays "Hello, you've hit 8080/foo" - this makes sense 2. Navigate to localhost:9090/foo in the same tab - browser displays "Hello, you've hit 8080/foo" - this does not make sense since I've changed the port 3. Navigate to localhost:9090/foo/bar - browser displays "Hello, you've hit 8080/foo/bar" - this really does not make sense since I've changed the port and the path 4. Hard refresh (Ctrl-Shift-R) - browser displays "Hello, you've hit 9090/foo/bar" I've tried this with a brand new install of the latest FF, running in safe mode, and the issue is still present. I don't know what is causing this issue, but as a web developer that frequently runs multiple local servers, it's infuriating. The servers on the different ports don't need to be in the same tab to mess with each other either. I've tried this with Chrome on the same computer, and it works perfectly, so it's not a problem with the network stack on my laptop. Has anyone else experienced something like this? EDIT: I noticed that when I use separate container tabs, this issue goes away. This helps a little, but I still have use cases where this does not help.

Modifié le par natemara

Toutes les réponses (8)

more options

If you check your logs on the server, can you tell whether Firefox is hitting the correct server each time, or whether it is ignoring the port? (I don't know if you can determine that from a combined log...) Obviously Firefox should NOT ignore the port when making a request.

If Firefox is hitting the correct server, it sounds like a cache problem. I don't know why the cache would disregard the port number. Does it make any difference if you send a cache-control: no-store header?

more options

Based on the logs, Firefox is definitely ignoring the port until I do a hard refresh.

more options

I've tried adding the cache-control header, and it doesn't help. I've also tried changing the port number to a port with nothing running on it, but it still sends the request to the old port. In the attached pic, there is nothing running on my port 1200.

more options

Hmm, could you try minimizing DNS caching. I think these are the relevant settings:

(1) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button promising to be careful or accepting the risk.

(2) In the search box above the list, type or paste dnsc and pause while the list is filtered

(3) Double-click each preference to display a dialog where you can enter the desired value, then click OK:

  • network.dnsCacheEntries => try reducing to 1
  • network.dnsCacheExpiration => try reducing to 1
  • network.dnsCacheExpirationGracePeriod => try reducing to 1

Does that make any difference?

more options

That did not make any difference, no.

more options

Can you test whether the problem is specific to IPv6 addressing? There's a separate preference for that. This isn't a fix, but could be useful information when you formally file a bug.

(1) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button promising to be careful or accepting the risk.

(2) In the search box above the list, type or paste dns and pause while the list is filtered

(3) Double-click the network.dns.disableIPv6 preference to switch the value from false to true


To file a bug:

more options

That did not change the behavior at all. Thanks though.

more options