-
Notifications
You must be signed in to change notification settings - Fork 821
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
[WSL 2] can't access container in WSL from Windows #4170
Comments
You have to use the ip address of WSL 2 (as it is a hyper-v container). you can do so by running ip addr | grep eth0 within WSL 2 terminal, and you can use that ip address to access any port. You might have to play with the firewall too. |
Isn't that obvious, haha. Thanks for pointing that out, solved my problem big time. I keep recalling someone from one of the WSL 2 presentation I watched saying that WSL 2 networking environment is the same as native Windows environment....etc perhaps he was referring to future release |
Its worth to say that with WSL (version 1) localhost/127.0.0.1 works fine. But once updated to WSL 2, its really necessary to run with local eth0 IP address. |
The solution works for me. |
Unable to access localhost from Windows
start container in WSL with
docker run -p 9001:8080 adminer
curl http://localhost:9001
returned with result no problemhowever when I performed the same curl command from Windows land, the connection was refused
curl: (7) Failed to connect to localhost port 9001: Connection refused
check with netstat under Windows, and confirmed port 9001 is not visible from Windows
Microsoft Windows [Version 10.0.18917.1000]
Ubuntu 18.04.2 LTS
Docker version 18.09.6, build 481bc77
Ubuntu installed from Microsoft Store and converted to WSL 2 as per official Microsoft instruction
Docker installed as per official Docker guide for Ubuntu
The text was updated successfully, but these errors were encountered: