为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Firefox loads wrong port on localhost unless hard refreshed

  • 8 个回答
  • 1 人有此问题
  • 1 次查看
  • 最后回复者为 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.

由natemara于修改

所有回复 (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