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

Accessing a WSL 2 distribution from your local area network (LAN) not working #2061

Open
Olcod opened this issue Nov 18, 2024 · 1 comment
Open
Assignees

Comments

@Olcod
Copy link

Olcod commented Nov 18, 2024

Type of issue

Code doesn't work

Feedback

Using Ubuntu-24-04 WSL2 distro:

PS C:\WINDOWS\system32> wsl -l -v                                                                                                                                                            NAME                   STATE           VERSION                                                                                                                                           * Ubuntu-24.04           Stopped         2                                                                                                                                                   docker-desktop-data    Running         2                                                                                                                                                   docker-desktop         Running         2

I ran the netsh command to add windows port mapping:

PS C:\WINDOWS\system32> netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=8080 connectaddress=172.17.145.122 

The WSL IP is correct:

PS C:\WINDOWS\system32> wsl hostname -I                                                                                                                                                    172.17.145.122

When I try to run Gatus container running, on the WSL distro docker run -p 8080:8080 --name gatus twinproduction/gatus, this is what I get:

~$ docker run -p 8080:8080 --name inline-gatus twinproduction/gatus
docker: Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:8080 -> 0.0.0.0:0: listen tcp4 0.0.0.0:8080: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.

Removing the netsh interface portproxy fixes docker error, but then I cannot access the container on host's private IP.
Without the portproxy, I can access the container on localhost:8080 and on 172.17.145.122:8080, host's private IP requests time out.

Page URL

https://learn.microsoft.com/en-us/windows/wsl/networking

Content source URL

https://github.com/MicrosoftDocs/wsl/blob/main/WSL/networking.md

Author

@mattwojo

Document Id

f9e21bfa-6316-7d45-3b34-834a78bcaf0f

@taoyouh
Copy link

taoyouh commented Dec 11, 2024

Just a thought: maybe we need to setup a rule in Windows firewall?

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

No branches or pull requests

3 participants