Repository navigation
Open
Labels
Description
Windows Version
Microsoft Windows [Version 10.0.26100.4202]
WSL Version
2.5.7.0
Are you using WSL 1 or WSL 2?
- WSL 2
- WSL 1
Kernel Version
6.6.87.1-1
Distro Version
Ubuntu 24.04
Other Software
No response
Repro Steps
Preparation
- Set WSL to use mirrored networking mode, make sure systemd is enabled, and leave everything else default.
- Reboot Windows to make sure the settings take effect. (The reboot has been necessary for me, I'm not sure about everyone else's situation.)
Scenario A - Docker 101 served from port 80
In WSL, run docker run --rm -p 80:80 docker/getting-started to start serving Docker 101 tutorial from port 80.
Scenario B - Serve a Next.js dev app from port 3000
- In WSL, run
npx create-next-app@latestto create a Next.js app. cdinto the project directory, and runnpm run devto start a dev server at port 3000.
Scenario C - Serving various Supabase services with Docker from port 5432*
- In WSL, run
npx create-next-app@latestto create a Next.js app. cdinto the project directory, and runnpm install supabase --save-devto install Supabase as a project dev dependency.- Run
npx supabase initand thennpx supabase startto start various containerised services - they should occupy port 54321, 54323 and 54324.
Expected Behavior
These URLs should all be reachable from both within WSL and from host Windows:
- http://localhost:80
- http://localhost:3000
- http://localhost:54321
- http://localhost:54323
- http://localhost:54324
- http://127.0.0.1:80
- http://127.0.0.1:3000
- http://127.0.0.1:54321
- http://127.0.0.1:54323
- http://127.0.0.1:54324
Actual Behavior
- All URLs listed were only reachable from within WSL.
- Loading any of the URLs in MS Edge running in host Windows resulted in (address differed for each URL):
I also tried requesting using Bruno, and I always got
Hmmm… can't reach this page localhost refused to connect. Try: Search the web for [localhost](https://www.bing.com/search?form=ANLKDR&q=localhost) Checking the connection [Checking the proxy and the firewall](chrome-error://chromewebdata/#buttons) ERR_CONNECTION_REFUSEDconnect ETIMEDOUT 127.0.0.1:3000(port differed for each URL).
Additional troubleshooting I've done
- Installed a brand-new Ubuntu 24.04 distro and tested from there - got same issue.
- Changed to NAT networking mode while leaving everything else unchanged - didn't get the same issue, i.e. can reach WSL from Windows.
- Tried
systemctl disable network-manager.serviceandsystemctl disable NetworkManager.service- neither worked since neither service existed. - Realised there's
systemd-networkd.serviceand it was already disabled; in vain hope, tried enabling & starting the service and then stopping & disabling the service - in the end, nothing changed i.e. still got the same issue. - Tried both Hyper-V firewall commands noted at https://learn.microsoft.com/en-us/windows/wsl/networking#mirrored-mode-networking - made no difference i.e. still got the same issue.
- Played with disabling/enabling the "Hyper-V" and/or the "Windows Hypervisor Platform" Windows features - made no difference i.e. still got the same issue.
Diagnostic Logs
Reacted by novum-copilot019, Yong Zhang, Locietta, Kristijan, Pasha Suprunchuk and ParkerHGordon
Activity
github-actions commentedon May 30, 2025
Diagnostic information
IbrahimTanyalcin commentedon Jun 2, 2025
I have an unrelated issue across devices on WSL2 even with older docker images that used to work. What is broken in my case is the detection of whether the app is running as container or not. And to do that, the old school method is to
grepinside/proc/1/cgroupand check if it matchesdocker|lxc. This recently stopped working, across WSL2, across docker versions suddenly.Did they push something on the wsl kernel?
The above check is important because if running inside container, you listen to
0.0.0.0:3000otherwise127.0.0.1:3000. I believe somewhere in your stack, a similar check has failed resulting in the behavior you observe: reachable inside WSL, but otherwise EMPTY response from windows because it is not listening on 0.0.0.0gaac510 commentedon Jun 5, 2025
Ibrahim Tanyalcin (@IbrahimTanyalcin) Thanks for the input. What you described is a little over my head. Does the
cgroupissue only impact docker containers running inside a WSL distro? Or does it impact WSL distros themselves?I did an additional check based on your info, which was to check if my (only) distro supports cgroup v2 following this, and I did get
nodev cgroup2.Also, my issue occurs even in scenario B where a web app was not served from a docker container. Does this mean I'm more likely experiencing a different issue?
WangMinan commentedon Jun 11, 2025
same issue
kjkent commentedon Jul 11, 2025
Similar issue here. It seems that binding to
0.0.0.0vslocalhostis involved, at least in my case. However, there's something non-intuitive/quirky/broken with the forwarding oflocalhostbetween Windows host and Linux VM. Example:Inside WSL, start an Astro dev server:
pnpm run devBy default, this listens to
localhostonly. Similarly, WSL sets the linux hosts file, with127.0.0.1defininglocalhost. WSL's own settings default tolocalhostForwarding=truehttp://localhost:4321.curl http://localhost:4321works.curl http://localhost:4321times out (error 28)curl http://127.0.0.1returns a "couldn't connect" error (error 27).Stop the dev server and re-run to bind to all host addresses:
pnpm run dev --hosthttp://localhost:4321,http://10.255.255.254:4321, andhttp://<the host's LAN IP>localhost:4321So, in order for Windows to be able to connect to a server in WSL via
localhost, the server needs to be listening on all addresses, not justlocalhost.HeavenZhi commentedon Jan 12, 2026
I have the same problem with WSL on my laptop, but strangely, sometimes mirrored mode works fine, but the problem reappears once my computer connects to another network.
q1uxu commentedon Feb 2, 2026
Similar too. My old laptop works well, but my new laptop do not work. They use the same wsl network config.
yongzhang commentedon Feb 27, 2026
same issue, this works for me previously but stopped working a few months ago and never work again
Christophoclese commentedon May 4, 2026
Similar trouble here with a uvicorn python web app in WSL2. No matter if bound to 0.0.0.0 or Windows IP, when attempting to reach the webserver from the Windows host by IP, the connection appears to time out or is refused. When using localhost to initiate the connection succeeds.
A packet capture shows that while the intial SYN is being received on eth1 in WSL guest, it responds with SYN-ACK on lo which triggers a RST on lo:
hot-tofu-curd commentedon Jul 31, 2026
I can reproduce this issue with native Docker Engine installed directly inside a Debian WSL distribution (not Docker Desktop). The documented
--network hostworkaround succeeds, while Docker bridge networking with a published port times out from the Windows host.Environment
Microsoft Windows [Version 10.0.22621.6060](22H2, Core edition)2.7.11.06.18.33.2-microsoft-standard-WSL2Debian GNU/Linux 12 (bookworm)20.10.24+dfsg1(native/usr/bin/dockerinside Debian)overlay2systemd/2wslinfo --networking-mode:mirroredRelevant
.wslconfig:WSL correctly warns that
localhostForwardingis ignored in mirrored mode.Bridge/published-port reproduction
I started a custom Apache image using Docker's default bridge network and published container port 80:
Docker reported the expected publication:
Inside WSL, port 80 was listening on both IPv4 and IPv6, and the service worked:
Result:
HTTP/1.1 200 OKfromApache/2.4.68 (Unix)with the expected HTML page.From Windows PowerShell, both of these timed out:
Access through the mirrored host/LAN address also timed out.
Checks already performed
W3SVCwas stopped and its startup type was set to Disabled.netstat/Get-NetTCPConnectionshowed no Windows process listening on TCP port 80.ssshowed Docker listening on0.0.0.0:80and[::]:80.The rule reports:
Adding this rule did not make the bridge-published port reachable from Windows.
Host-network control test
I stopped the bridge-mode container and ran the same image using the host networking namespace:
With this container running, the following Windows request succeeds immediately and returns the expected HTML:
This A/B result appears to isolate the failure to the interaction between WSL mirrored networking and Docker's default bridge/published-port path, rather than Apache, the image, IIS, a Windows port conflict, or the basic Windows-to-WSL localhost path.
I can collect and provide the full WSL networking logs privately if a Microsoft maintainer needs them. I have not attached them publicly because networking logs may contain host or network identifiers; please reply with the preferred private submission method. I can also retest with a newer Docker Engine build if that would help isolate whether the Docker version affects this behavior.