Forum Discussion
Unable to Access Docker Container Services on WSL2 from Localhost but Accessible via Public IP
Hello!
I have an Ubuntu distro running on WSL2 with Mirrored Networking enabled, so the virtual machine and the host share IP and adapter. Inside the distro, I have Docker installed with several services running, listening on different ports. I can correctly access the services running directly on the virtual machine (e.g., SSH on port 22) using localhost:22.
My problem is that I cannot access the Docker container services from the host using the local IP (127.0.0.1, localhost, 192.168.0.9). The strange thing is that I can access them through my public IP over the Internet.
Diagram:
Windows 11 Host (Public IP: 10.20.30.40. Private IP: 192.168.0.9) | |__WSL2 Ubuntu (Public IP: 10.20.30.40. Private IP: 192.168.0.9) | |__SSH Server (Accessible from 10.20.30.40:22 and localhost:22) | |__Docker | |__Service 1 (Only accessible from 10.20.30.40:80) |__Service 2 (Only accessible from 10.20.30.40:443)
I have already done several tests, reinstalling various different distros and consulting the documentation, but I couldn't find the solution. Thank you very much.
Here is my .wslconfig config:
[wsl2] kernelCommandLine=ipv6.disable=1 [experimental] networkingMode=mirrored hostAddressLoopback=True