Accessing webserver inside WSL from Windows(chrome)

Viewed 27

I'm using WSL(v2) and have a web server running inside it.

$ kubectl get nodes
NAME                 STATUS   ROLES           AGE     VERSION
kind-control-plane   Ready    control-plane   3d21h   v1.25.0

And I can ping my "website" from within WSL [ping mysite.com] just fine

On my Windows side, I have Docker Desktop running.
Under Containers:

NAME                IMAGE                STATUS   PORTS
kind-control-plane  kindest/node:<none>  Running  443,42725,80

I have also enabled all [WSL] related options under Docker Desktop -> Settings

I want to access this website in Chrome and tried:

localhost:443 = err 400
localhost:42725 = Client sent an HTTP request to an HTTPS server. With https, err 403
localhost:80 = err 404

I also tried adding the port 42725 to my firewall allowed list but nothing seems to change.

I searched and found multiple Q&As pointing me here:
https://learn.microsoft.com/en-us/windows/wsl/networking
I tried these:

netsh interface portproxy add v4tov4 listenport=80listenaddress=0.0.0.0 connectport=80connectaddress={hostname -I}
netsh interface portproxy add v4tov4 listenport=443listenaddress=0.0.0.0 connectport=443connectaddress={hostname -I}

but nothing changes.
However, when I do this

netsh interface portproxy add v4tov4 listenport=42725listenaddress=0.0.0.0 connectport=42725connectaddress={hostname -I}

And then try to restart:

$ docker start kind-control-plane
Error response from daemon: Ports are not available: exposing port TCP 127.0.0.1:42725 -> 0.0.0.0:0: listen tcp 127.0.0.1:42725: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
Error: failed to start containers: kind-control-plane

I also tried a completely different [listenport] but it didn't work either.

I'm actually not sure what ports to put inside the listenport/connectport options. Also, should I change listenaddress=0.0.0.0 to something else? Any suggestions? Thanks!

0 Answers
Related