Tech Programing


Could not connect to TCP port: Connection refused when trying to open Expo app on Android Emulator in WSL2

1 min read

I’ve been following this guide https://medium.com/@pellea/using-adb-with-wsl2-7aebbb070a47 and so far have gotten to the point where WSL2 can see the emulator(s) running on Windows through Android Studios -> AVD manager. For example, on both Windows and WSL2, adb devices correctly shows:

List of devices attached
emulator-5554   device

However, when I go to my expo app and try to launch the Android emulator, I get the following error message:

Couldn't start project on Android: could not connect to TCP port 5554: Connection refused

This is after I’ve tried the following:

  1. exporting ADB_SERVER_SOCKET=tcp:<MY IP>:5037 in my WSL2 profile(s)
  2. Unblocking WSL2 vEthernet connections from my Windows firewall via (from the above link)
Set-NetFirewallProfile -DisabledInterfaceAliases "vEthernet (WSL)"
  1. I’ve portforwarded 5554 from Windows to WSL2, as well as 5037 (from to
$WSL_CLIENT = bash.exe -c "ip addr show eth0 | grep -oP '(?<=inets)d+(.d+){3}'";
$WSL_CLIENT -match 'd{1,3}.d{1,3}.d{1,3}.d{1,3}';
$WSL_CLIENT = $matches[0];
iex "netsh interface portproxy add v4tov4 listenport=5554 listenaddress= connectport=5554 connectaddress=$WSL_CLIENT"

The ports are as follows:

netsh interface portproxy show all

Listen on ipv4:             Connect to ipv4:

Address         Port        Address         Port
--------------- ----------  --------------- ----------       8081   8081         5037       5037       5554    5554

Source link



發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *