Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web apps from WSL2 not accessible from other devices in same LAN #12404

Open
1 of 2 tasks
PoProstuWitold opened this issue Dec 23, 2024 · 6 comments
Open
1 of 2 tasks
Labels

Comments

@PoProstuWitold
Copy link

Windows Version

Microsoft Windows [Version 10.0.22631.4602]

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 24.04

Other Software

Windows 11 Education,

My .wslconfig:

[wsl2]
memory=8GB
networkingMode=mirrored
defaultVhdSize=256GB
autoProxy=true
dnsTunneling=true
firewall=true

[experimental]
autoMemoryReclaim=gradual
hostAddressLoopback=true

Repro Steps

Run following command from this issue in elevated prompt and then launch some web app (in my case simple Node.js server running on port 3005).

A safer alternative is to Only allow connection to wsl in a Trusted (Private) network:

New-NetFirewallHyperVRule `

-DisplayName 'Allow All Inbound Traffic to WSL in Private Network' `

-Name 'WSL Rule' `

-Profiles Private `

-Direction Inbound `

-Action Allow `

-VMCreatorId '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' `

-Enabled True

This would block connection to wsl in a public (or untrusted) network, which is good.

In case you want to delete the rule, run:

Remove-NetFirewallHyperVRule -Name 'WSL Rule'

Originally posted by @tusharsnx in #10769

Expected Behavior

Web app is accessible on other LAN devices at WSL2_IPv4:PORT

Actual Behavior

Web app is only accesible on host machine via localhost:PORT and WSL2_IPv4:PORT

Diagnostic Logs

WslLogs-2024-12-23_16-15-20.zip

@PoProstuWitold
Copy link
Author

It was working last couple of days and today suddenly stopped. No idea why

Copy link

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Diagnostic information
.wslconfig found
Detected appx version: 2.3.26.0

@wpwoodjr
Copy link

wpwoodjr commented Jan 8, 2025

It's working for me today using the same rule

@CatalinFetoiu
Copy link
Collaborator

@PoProstuWitold thanks for reporting the issue

can you please share the output of the following command? I suspect that your Windows machine is connected to a network that is not a private network and the rule you shared does not apply

Get-NetIPConfiguration -All -Detailed

Does adding a similar rule, but without the "-Profiles Private" argument, solve the issue?

@PoProstuWitold
Copy link
Author

@PoProstuWitold thanks for reporting the issue

can you please share the output of the following command? I suspect that your Windows machine is connected to a network that is not a private network and the rule you shared does not apply

Get-NetIPConfiguration -All -Detailed

Does adding a similar rule, but without the "-Profiles Private" argument, solve the issue?

Hello. I tried creating rules for All profiles and it doesnt't change anything but somehow the issue persist only on my home network. Everything works fine when connected to my Android mobile Internet and my work LAN so I assume it's something messed up in my home network.

Sometimes it also fixes itself with my home LAN after temporary switching to mobile Internet.

@CatalinFetoiu
Copy link
Collaborator

thanks @PoProstuWitold for following up. can you please collect networking logs using instructions at https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#collect-wsl-logs-for-networking-issues ?

The script will generate a zip with name starting with "WslNetworkingLogs"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants