rancher-desktop: WSL cannot connect to localhost with Network Tunnel enabled

Actual Behavior

When WSL Network Tunnel is enabled localhost cannot be accessed from the WSL distro

Steps to Reproduce

  1. Enable Network Tunnel in the WSL preferences
  2. Start a container hosting locally from within WSL a. docker run --rm -p 8080:80 nginx:stable
  3. Try to access the locally running container from within WSL a. In a WSL shell run curl http://localhost:8080

Result

The curl command fails

$ curl http://localhost:8080
curl: (7) Failed to connect to localhost port 8080 after 0 ms: Connection refused

Expected Behavior

I expect to get a response from the container running locally. This is the response I get when running curl http://localhost:8080 with the exact same repo steps but with Network Tunnel disabled.

$ curl http://localhost:8080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

Additional Information

At times there have been some connection issues when running docker containers or pulling images. As a company we are required to work connected to a VPN. We also host our own private image registry that is only accessible while connected to the VPN. This could be the reason for some of the inconsistent connectivity issue we experience. Enabling the Network Tunnel fixes these issues, but having it enabled is preventing us from accessing the containers that are started from WSL.

Also, I according to Rancher Desktop release notes, the Network Tunnel will be the default in version 1.13 and removed in 1.14. Soon we will not have the ability to disable the Network Tunnel.

I was able to reproduce the issue on the version of Rancher I an running, 1.12.3, and on another developer’ machine who was using version 1.9.1.

Rancher Desktop Version

1.12.3

Rancher Desktop K8s Version

N/A

Which container engine are you using?

moby (docker cli)

What operating system are you using?

Windows

Operating System / Build Version

Windows 10 Pro 22H2

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

None

Windows User Only

Yes, we use a privately host VPN

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

@gpechiro thanks for filing this. Currently when the network tunnel is enabled, from within WSL distro you can only access your app using the WSL IP address from the host side and not the localhost.

e.g: on your windows host:

PS C:\Users\Nino> ipconfig

Windows IP Configuration

Ethernet adapter vEthernet (WSL):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::2262:72:fb18:bb62%31
   IPv4 Address. . . . . . . . . . . : 172.27.176.1    <===== this address
   Subnet Mask . . . . . . . . . . . : 255.255.240.0
   Default Gateway . . . . . . . . . :

and then from WSL distro:

curl 172.27.176.1:8080 

It should work fine. Let me know if that works for you.

I’m going to close this issue, please give 1.14 a try, if you encounter any further issues, feel free to re-open.

@mathisgauthey thanks for bringing this up, we have made some changes recently that should address this specific issue you can take a look at here. This change will be included in our upcoming release 1.14.

I thought I remember reading 1.12 release notes that your timeline was started and 1.14 would be the release where the old network stack was removed. Has that timeline shifted?

Yes, the timeline has shifted because the new stack hasn’t reached feature parity yet (exactly this issue, that we are commenting on). It is no longer considered experimental, but not yet the default.

@gpechiro we have a plan to address this, however, the workaround that I provided you should work for you in the meanwhile.