WSL: I can't access to my nginx server in docker in wsl2 via my web-browser

Windows Version

Microsoft Windows [version 10.0.22631.4460]

WSL Version

2.3.26.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.167.4-1

Distro Version

Ubuntu 20.04

Other Software

Docker Desktop (Windows), version v27.3.1

Repro Steps

  • Start a docker desktop and nginx via WLS2
  • Try to access via windows browser localhost:80 or 127.0.0.1:80
  • Unable to access it.

Expected Behavior

can able to access it.

Actual Behavior

question: I can not access to my nginx server in docker in wsl2 via my local web-browser by http://localhost:80, it shows:ERR_CONNECTION_TIMED_OUT; And:

  1. I can access to it by POSTMAN or curl http://localhost:80 in cmd;
  2. I found it can works when I use wireshark to analyze. But it does’t work when I stop wireshark;
  3. I have try to stop the firewall of my windows, it still does’t work;
  4. In addition, I use clash in my windows, but there is setting of Bypass for local;

Diagnostic Logs

No response

About this issue

Most upvoted comments

An interesting thing that you mentioned:

  • I found it can works when I use wireshark to analyze. But it does’t work when I stop wireshark;

Do you mean that you’re able to reach the localhost:8000 from browser only when wireshark is running?

This could be linked to https://github.com/microsoft/WSL/issues/11600#issuecomment-2187915259

are you using mirrored mode?