androidnestjswindows-subsystem-for-linuxandroid-virtual-devicewsl-2

Access to service on WSLS from Virtual Device


I have a problem concerning the connection between my virtual device and my server, which locally runs on WSL2, and my virtual device. On a VM where everything was installed on the same host, I was using the address 10.0.2.2:. But this doesn't work.

On my WSL2 distro, I installed Docker. From what I can see from VSCode (which is plugged into my WSL distro), I have port forwarding done automatically. So from my virtual device, I can access the various services hosted by Docker using 10.0.2.2:. The exposed containers are linked to the process: /bin/docker-proxy.

My service (not hosted by Docker) is a NestJS backend node.

  1. First of all, where does the automatic port translation I see in VSCode (Console > Port tab) come from?

  2. Do you have any clues about my basic problem?

I've tried adding inbound rules in windows, configuring port translation in (via Netsh) but nothing works...


Solution

  • This was due to the default configuration of the NestJs listening server. I override the hostname address to 127.0.0.1.