2

Running on Ubuntu 20.04 (WSL2):

➜  ~ adb --version
Android Debug Bridge version 1.0.41
Version 33.0.1-8253317
Installed as /home/eliya/dev/Android/platform-tools/adb

Running

➜  ~ adb devices
adb W 04-28 16:43:11 20145 20145 network.cpp:149] failed to connect to '172.23.160.1:5037': Connection timed out
* cannot start server on remote host
adb: failed to check server version: cannot connect to daemon at tcp:172.23.160.1:5037: failed to connect to '172.23.160.1:5037': Connection timed out

Running

➜  ~ adb start-server
adb W 04-28 16:47:17 21475 21475 network.cpp:149] failed to connect to '172.23.160.1:5037': Connection timed out
* cannot start server on remote host
error: cannot connect to daemon at tcp:172.23.160.1:5037: failed to connect to '172.23.160.1:5037': Connection timed out

But when I run it as root, it seems to work fine:

➜  ~ sudo adb devices
List of devices attached
XXXXXXXXXXXXXX  device

How can I make adb to work without sudo permissions?

Update 1

running adb -H localhost ... seems to be ok. What am I missing here?

Update 2

Running in Windows:

PS C:\Users\coeli> adb start-server

and then in WSL2 (hangs for a while and then fails):

➜  ~ adb devices
List of devices attached
* cannot start server on remote host
error: cannot connect to daemon at tcp:172.23.160.1:5037: Connection timed out
Eliya Cohen
  • 10,716
  • 13
  • 59
  • 116

3 Answers3

3

If you want WSL to be able to talk with the adb server running in Windows, you have to start the server in such a way that it will listen on all interfaces, not just the default one. This is done with -a, like so:

.\adb.exe -a nodaemon server start

You can also put a -P in there if you want to use something other than the default port of 5037, like this:

.\adb.exe -a -P 5037 nodaemon server start

If you still have problems, double-check your Windows Firewall. However, since this is all local interface stuff, that shouldn't be a factor in most installations.

cjbarth
  • 4,189
  • 6
  • 43
  • 62
0

I think I may have found a fix for this. In my case, the issue was caused by not installing sdkmanager properly. I used openjdk11 instead of openjdk8, which is required by the sdkmanager to run properly. In anycase, following this tutorial https://gist-github-com.translate.goog/georgealan/353a548814fe9b82a3a502926c7a42c6?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=wapp#passo-4%C2%BA should allow you to get it up and running without needing to use sudo commands. Article is for ReactNative but you dont need to follow the whole thing

0

If anyone else comes across this, check your ADB_SERVER_SOCKET environment variable. I had it set to something because of some previous troubleshooting but forgot to clean it up. Removing it from my .bashrc fixed the issue.