I am developing inside a docker container using the VSCode Remote Containers extension. I start a server inside the container which listens at port 3342 and would like to access the webpage using other devices in the same network.
I forward port 3342 inside the Ports tab and I am able to open the webpage in my host OS using localhost:3342
and 127.0.0.1:3342
, but failed when using my local IP address 10.10.11.90:3342
.
I checked the listening ports in my host OS:
> sudo lsof -nP -iTCP:3342 | grep LISTEN
Code\x20H 4181 alvin 27u IPv4 0x65c113c13860c1b7 0t0 TCP 127.0.0.1:3342 (LISTEN)
It seems that VSCode is only listening at 127.0.0.1
.
Is there a way for me to tell VSCode to listen at 0.0.0.0
so that it accepts requests from all network interface?
My configuration:
In VSCode settings, set to "All Interfaces" here:
Remote: Local Port Host
allInterfaces
If it's set to "localhost", devContainers forwarded ports will only listen to 127.0.0.1
.
When set to "allInterfaces", it will listen to 0.0.0.0
.