I've been tinkering around with WSL-2 for a while now and don't exactly understand how traffic is routed between the host and WSL-2 dist.
In some sources it seems like all ports used by WSL-2 automatically become available to the host machine. Such as in this tutorial by Microsoft.
Similarly I managed to host a Jupyter instance which is available directly on my host machine through localhost:8888.
However, when trying other services, such as ssh (also tried on a non-standard port) the port does not automatically become available through localhost and I have to use the IP address assigned to my WSL distro (the one from wsl hostname -I)
To make the services available through localhost I found this portforwarding script, which worked. But I would like to understand why it was needed.
Why is port forwarding needed for some services, but not all?