Skip to content
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

[Bug]: android-tools (adb) cannot connect to daemon #7946

Open
ghost opened this issue Nov 7, 2021 · 56 comments
Open

[Bug]: android-tools (adb) cannot connect to daemon #7946

ghost opened this issue Nov 7, 2021 · 56 comments
Labels
bug report Something is not working properly inactive No activity in a certain period of time

Comments

@ghost
Copy link

ghost commented Nov 7, 2021

Problem description

when i trying to connect to adb i'm getting this error

~ ❯ adb pair localhost:42062
Enter pairing code: 269850
* daemon not running; starting now at tcp:5037
* daemon started successfully
* daemon still not running
error: cannot connect to daemon at tcp:5037: Not a data message

Screenshot-20211107-182144-Termux

this error has never happened to me before

What steps will reproduce the bug?

connecting with adb via wireless

What is the expected behavior?

No response

System information

termux-info:

Application version:
0.117
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://termux.librehat.com/apt/termux-main/ stable main
# science-repo (sources.list.d/science.list)
deb https://packages.termux.org/apt/termux-science science stable
# game-repo (sources.list.d/game.list)
deb https://packages.termux.org/apt/termux-games games stable
# x11-repo (sources.list.d/x11.list)
deb https://packages.termux.org/apt/termux-x11 x11 main
Updatable packages:
All packages up to date
Android version:
11
Kernel build information:
Linux localhost 4.4.177-21848546 #1 SMP PREEMPT Tue Jun 8 18:55:47 KST 2021 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-A205F
@ghost ghost added the bug report Something is not working properly label Nov 7, 2021
@finagolfin
Copy link
Member

@ian4hu, is it working for you?

@ian4hu
Copy link
Contributor

ian4hu commented Nov 8, 2021

@elwaer-m it (31.0.3) works on my device like bellow.

~ $ pkg install android-tools
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  android-tools
0 upgraded, 1 newly installed, 0 to remove and 17 not upgraded.
Need to get 0 B/1158 kB of archives.
After this operation, 4276 kB of additional disk space will be used.
Selecting previously unselected package android-tools.
(Reading database ... 14993 files and directories currently installed.)
Preparing to unpack .../android-tools_31.0.3_aarch64.deb ...
Unpacking android-tools (31.0.3) ...
Setting up android-tools (31.0.3) ...
~ $ adb version
Android Debug Bridge version 1.0.41
Version 31.0.3-android-tools
Installed as /data/data/com.termux/files/usr/bin/adb
~ $ adb devices
List of devices attached

~ $ adb pair localhost:41621
Enter pairing code: XXXXXX
Successfully paired to localhost:41621 [guid=adb-XXXXX-FTsFiT]
~ $ adb devices -l
List of devices attached

~ $ adb connect localhost:41615
connected to localhost:41615
~ $ adb devices
List of devices attached
localhost:41615 device

~ $

I am not sure what your android-tools package version.

@ian4hu
Copy link
Contributor

ian4hu commented Nov 8, 2021

@elwaer-m In your screenshot I see a warning about * daemon still not running error: cannot connect to daemon at tcp:5037: Not a data message , It is said that your adb server daemon is not started and it dose not listen on port 5037.

You should find out is there any other app is listen on 5037. or the adb-server is started.
The corrent adb server should like bellow

~ $ ps aux | grep adb | grep server
u0_a244   9149  0.0  0.0 2236892 8396 ?        S<sl  1970   0:00 adb -L tcp:5037 fork-server server --reply-fd 4
~ $

you can try to start adb server manually by adb kill-server && adb start-server .

@ghost
Copy link
Author

ghost commented Nov 8, 2021

@ian4hu

~ ❯ adb version
Android Debug Bridge version 1.0.41
Version 31.0.3-android-tools
Installed as /data/data/com.termux/files/usr/bin/adb
~ ❯ adb devices
* daemon not running; starting now at tcp:5037                         * daemon started successfully
List of devices attached
* daemon still not running
error: cannot connect to daemon at tcp:5037: Not a data message        
~ ❯ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
u0_a1326 22437  7.7  4.0 6096580 113220 ?      S<l   1970   0:56 com.teu0_a1326 23186  0.1  0.1 2134008 3744 pts/0    S<s   1970   0:00 /data/
u0_a1326 25614  0.1  0.1 2201784 4408 ?        S<sl  1970   0:00 adb -L
u0_a1326 25639  0.0  0.0 2132076 2096 pts/0    R<+   1970   0:00 ps aux
~ ❯ kill 25614
~ ❯ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
u0_a1326 22437  7.9  4.1 6096648 115636 ?      S<l   1970   0:58 com.te
u0_a1326 23186  0.1  0.1 2134008 3744 pts/0    S<s   1970   0:00 /data/u0_a1326 25675  1.0  0.0 2132076 2096 pts/0    R<+   1970   0:00 ps aux
~ ❯ adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
~ ❯ adb devices
* daemon not running; starting now at tcp:5037
ADB server didn't ACK
Full server startup log: /data/data/com.termux/files/usr/tmp/adb.11326.log
Server had pid: 25719
--- adb starting (pid 25719) ---
adb I 11-08 19:29:48 25719 25719 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-08 19:29:48 25719 25719 main.cpp:63] Version 31.0.3-android-tools
adb I 11-08 19:29:48 25719 25719 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-08 19:29:48 25719 25719 main.cpp:63]
adb F 11-08 19:29:49 25719 25719 main.cpp:155] could not install *smartsocket* listener: Address already in use

* failed to start daemon
adb: failed to check server version: cannot connect to daemon

@ian4hu
Copy link
Contributor

ian4hu commented Nov 8, 2021

@elwaer-m thanks for your details. Could you please attach the full '/data/data/com.termux/files/usr/tmp/adb.11326.log'

@ghost
Copy link
Author

ghost commented Nov 9, 2021

--- adb starting (pid 2457) ---
adb I 11-09 03:34:14  2457  2457 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-09 03:34:14  2457  2457 main.cpp:63] Version 31.0.3-android-tools
adb I 11-09 03:34:14  2457  2457 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-09 03:34:14  2457  2457 main.cpp:63] 
adb I 11-09 03:34:14  2457  2457 auth.cpp:417] adb_auth_init...
adb I 11-09 03:34:14  2457  2457 auth.cpp:152] loaded new key from '/data/data/com.termux/files/home/.android/adbkey' with fingerprint 69B47B078799BD12CC4321E54721ED82EB61087D8B1407269CA74311DD4332FA
adb I 11-09 03:34:14  2457  2457 auth.cpp:392] adb_auth_inotify_init...
--- adb starting (pid 2563) ---
adb I 11-09 03:34:24  2563  2563 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-09 03:34:24  2563  2563 main.cpp:63] Version 31.0.3-android-tools
adb I 11-09 03:34:24  2563  2563 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-09 03:34:24  2563  2563 main.cpp:63] 
adb F 11-09 03:34:25  2563  2563 main.cpp:155] could not install *smartsocket* listener: Address already in use

@ian4hu
Copy link
Contributor

ian4hu commented Nov 9, 2021

@elwaer-m It seems the adb server is stucked in start up smartsocket. Would you mind execute the follow steps and attach the log ? The follow steps will turn on adb trace and set adb server logging to /data/data/com.termux/files/home/adb.log, You can get the adb server trace log by cat /data/data/com.termux/files/home/adb.log;

~ $ export ANDROID_ADB_LOG_PATH=/data/data/com.termux/files/home/adb.log
~ $ export ADB_TRACE=all
~ $ adb kill-server
adb D 11-09 12:25:08  3448  3448 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 11-09 12:25:08  3448  3448 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 11-09 12:25:08  3448  3448 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 11-09 12:25:08  3448  3448 adb_trace.cpp:187]
adb D 11-09 12:25:08  3448  3448 adb_client.cpp:194] adb_kill_server
adb D 11-09 12:25:08  3448  3448 adb_io.cpp:107] writex: fd=3 len=13 30303039686f73743a6b696c6c 0009host:kill
adb D 11-09 12:25:08  3448  3448 adb_io.cpp:81] readx: fd=3 wanted=4
adb D 11-09 12:25:08  3448  3448 adb_io.cpp:97] readx: fd=3 wanted=4 got=4 4f4b4159 OKAY
~ $ adb start-server
adb D 11-09 12:25:14  3451  3451 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 11-09 12:25:14  3451  3451 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 11-09 12:25:14  3451  3451 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 11-09 12:25:14  3451  3451 adb_trace.cpp:187]
adb D 11-09 12:25:14  3451  3451 adb_client.cpp:346] adb_connect: service: host:start-server
adb D 11-09 12:25:14  3451  3451 adb_client.cpp:155] _adb_connect: host:version
* daemon not running; starting now at tcp:5037
adb D 11-09 12:25:14  3452  3452 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 11-09 12:25:14  3452  3452 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 11-09 12:25:14  3452  3452 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 11-09 12:25:14  3452  3452 adb_trace.cpp:187]
* daemon started successfully
~ $ cat $ANDROID_ADB_LOG_PATH
--- adb starting (pid 3395) ---
adb I 11-09 12:22:57  3395  3395 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-09 12:22:57  3395  3395 main.cpp:63] Version 31.0.3-android-tools
adb I 11-09 12:22:57  3395  3395 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-09 12:22:57  3395  3395 main.cpp:63]
adb D 11-09 12:22:57  3395  3395 transport.cpp:844] socketpair: (3,5)
adb D 11-09 12:22:57  3395  3395 transport_local.cpp:233] transport: local client init
adb I 11-09 12:22:57  3395  3395 auth.cpp:417] adb_auth_init...
adb D 11-09 12:22:57  3395  3398 transport_local.cpp:191] transport: client_socket_thread() starting
adb D 11-09 12:22:57  3395  3397 usb_linux.cpp:609] Created device thread
adb I 11-09 12:22:57  3395  3395 auth.cpp:152] loaded new key from '/data/data/com.termux/files/home/.android/adbkey' with fingerprint C9DB65937F17EC722F0AE48139E7D81B046AE9B74362BD81CCB26761C2EA4159
adb I 11-09 12:22:57  3395  3395 auth.cpp:392] adb_auth_inotify_init...
adb D 11-09 12:22:57  3395  3395 main.cpp:230] Event loop starting
adb D 11-09 12:22:57  3395  3395 fdevent_epoll.cpp:174] (fdevent 0: fd 7 R) got events 0x1
adb D 11-09 12:25:08  3395  3395 fdevent_epoll.cpp:174] (fdevent 2: fd 9 R) got events 0x1
adb D 11-09 12:25:08  3395  3395 sockets.cpp:399] LS(1): created (fd=4)
adb D 11-09 12:25:08  3395  3395 sockets.cpp:903] Connecting to smart socket
adb D 11-09 12:25:08  3395  3395 sockets.cpp:891] Creating smart socket
adb D 11-09 12:25:08  3395  3395 sockets.cpp:898] SS(0)
adb D 11-09 12:25:08  3395  3395 fdevent_epoll.cpp:174] (fdevent 4: fd 4 R) got events 0x1
adb D 11-09 12:25:08  3395  3395 sockets.cpp:353] LS(1): event_func(fd=4(==4), ev=0001)
adb D 11-09 12:25:08  3395  3395 sockets.cpp:164] LS(1): post adb_read(fd=4,...) r=13 (errno=0) avail=1048576
adb D 11-09 12:25:08  3395  3395 sockets.cpp:164] LS(1): post adb_read(fd=4,...) r=-1 (errno=11) avail=1048563
adb D 11-09 12:25:08  3395  3395 sockets.cpp:180] LS(1): fd=4 post avail loop. r=-1 is_eof=0 forced_eof=0
adb D 11-09 12:25:08  3395  3395 sockets.cpp:722] SS(0): enqueue 13
adb D 11-09 12:25:08  3395  3395 sockets.cpp:742] SS(0): len is 9
adb D 11-09 12:25:08  3395  3395 sockets.cpp:751] SS(0): 'host:kill'
adb server killed by remote request

@ghost
Copy link
Author

ghost commented Nov 9, 2021

@ian4hu

~ ❯ export ANDROID_ADB_LOG_PATH=/data/data/com.termux/files/home/adb.log
~ ❯ export ADB_TRACE=all
~ ❯ adb kill-server
adb D 11-09 13:09:54  1177  1177 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 11-09 13:09:54  1177  1177 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 11-09 13:09:54  1177  1177 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 11-09 13:09:54  1177  1177 adb_trace.cpp:187]
adb D 11-09 13:09:54  1177  1177 adb_client.cpp:194] adb_kill_server
cannot connect to daemon at tcp:5037: Not a data message
~ ❯ adb start-server
adb D 11-09 13:10:06  1243  1243 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 11-09 13:10:06  1243  1243 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 11-09 13:10:06  1243  1243 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 11-09 13:10:06  1243  1243 adb_trace.cpp:187]
adb D 11-09 13:10:06  1243  1243 adb_client.cpp:346] adb_connect: service: host:start-server
adb D 11-09 13:10:06  1243  1243 adb_client.cpp:155] _adb_connect: host:version
* daemon not running; starting now at tcp:5037
adb D 11-09 13:10:06  1244  1244 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 11-09 13:10:06  1244  1244 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 11-09 13:10:06  1244  1244 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 11-09 13:10:06  1244  1244 adb_trace.cpp:187]
ADB server didn't ACK
Full server startup log: /data/data/com.termux/files/home/adb.log
Server had pid: 1244
--- adb starting (pid 1244) ---
adb I 11-09 13:10:06  1244  1244 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-09 13:10:06  1244  1244 main.cpp:63] Version 31.0.3-android-tools
adb I 11-09 13:10:06  1244  1244 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-09 13:10:06  1244  1244 main.cpp:63]
adb D 11-09 13:10:06  1244  1244 transport.cpp:844] socketpair: (3,5)
adb D 11-09 13:10:06  1244  1244 transport_local.cpp:233] transport: local client init
adb D 11-09 13:10:06  1244  1246 usb_linux.cpp:609] Created device thread
adb D 11-09 13:10:06  1244  1247 transport_local.cpp:191] transport: client_socket_thread() starting
adb F 11-09 13:10:06  1244  1244 main.cpp:155] could not install *smartsocket* listener: Address already in use

* failed to start daemon
error: cannot connect to daemon
~ ❯ cat $ANDROID_ADB_LOG_PATH
--- adb starting (pid 430) ---
adb I 11-09 13:07:56   430   430 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-09 13:07:56   430   430 main.cpp:63] Version 31.0.3-android-tools
adb I 11-09 13:07:56   430   430 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-09 13:07:56   430   430 main.cpp:63]
adb D 11-09 13:07:56   430   430 transport.cpp:844] socketpair: (3,5)
adb D 11-09 13:07:56   430   430 transport_local.cpp:233] transport: local client init
adb I 11-09 13:07:56   430   430 auth.cpp:417] adb_auth_init...
adb D 11-09 13:07:56   430   433 transport_local.cpp:191] transport: client_socket_thread() starting
adb D 11-09 13:07:56   430   432 usb_linux.cpp:609] Created device thread
adb I 11-09 13:07:56   430   430 auth.cpp:152] loaded new key from '/data/data/com.termux/files/home/.android/adbkey' with fingerprint 69B47B078799BD12CC4321E54721ED82EB61087D8B1407269CA74311DD4332FA
adb I 11-09 13:07:56   430   430 auth.cpp:392] adb_auth_inotify_init...
adb D 11-09 13:07:56   430   430 main.cpp:230] Event loop starting
adb D 11-09 13:07:56   430   430 fdevent_epoll.cpp:174] (fdevent 0: fd 7 R) got events 0x1
--- adb starting (pid 1244) ---
adb I 11-09 13:10:06  1244  1244 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-09 13:10:06  1244  1244 main.cpp:63] Version 31.0.3-android-tools
adb I 11-09 13:10:06  1244  1244 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-09 13:10:06  1244  1244 main.cpp:63]
adb D 11-09 13:10:06  1244  1244 transport.cpp:844] socketpair: (3,5)
adb D 11-09 13:10:06  1244  1244 transport_local.cpp:233] transport: local client init
adb D 11-09 13:10:06  1244  1246 usb_linux.cpp:609] Created device thread
adb D 11-09 13:10:06  1244  1247 transport_local.cpp:191] transport: client_socket_thread() starting
adb F 11-09 13:10:06  1244  1244 main.cpp:155] could not install *smartsocket* listener: Address already in use
~ ❯

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Nov 9, 2021

@elwaer-m

The error is from here.

// If we told a previous adb server to quit because of version mismatch, we can get to this
// point before it's finished exiting. Retry for a while to give it some time. Don't actually
// accept any connections until adb_wait_for_device_initialization finishes below.

Considering that EADDRINUSE (Address already in use) is being thrown, that means address/port is already being used by some existing adb server. Do you have some other apps that may start a server? There are a few adb related apps and their server processes wouldn't show in ps output in termux since uid will be different. Try running adb shell "ps -ef | grep adb" from pc and see if some processes show. I don't have a physical android 12 device so haven't tested the command. Moreover, you may not be able to connect from pc if something has already connected to adb host daemon on your device.

Otherwise try restarting the device and see if that helps.

@ghost
Copy link
Author

ghost commented Nov 10, 2021

i don't have any server running or anything like that
and i saw a guy on discord have the same problem
Screenshot-20211110-041735
and looks like he using a samsung phone too
so this problem happening just in samsung phones maybe

@agnostic-apollo
Copy link
Member

agnostic-apollo commented Nov 10, 2021

i don't have any server running or anything like that

Just to confirm, you checked this from pc, not from termux, right? Termux user cannot access processes started by other apps.

so this problem happening just in samsung phones maybe

Have you previously used android-tools on your phone, like older version. Did you receive an android OS upgrade recently from Samsung?

Maybe try an alternative port for adb server. The adb command has the -P global option that can be used for custom port for server. It needs to be passed to every adb command.

So try adb -P 5038 start-server, adb -P 5038 pair localhost:<port>, adb -P 5038 connect localhost and adb -P 5038 shell. Or try an even higher port, like 50370. Maybe there is some port restriction, just a guess.

@ghost
Copy link
Author

ghost commented Nov 10, 2021

Just to confirm, you checked this from pc, not from termux, right?

i have not checking it from a pc sorry, i dont have access to one

Have you previously used android-tools on your phone, like older version. Did you receive an android OS upgrade recently from Samsung?

the older version of android-tools was working fine for me but after i updated it this problem come out

Maybe try an alternative port for adb server. The adb command has the -P global option that can be used for custom port for server. It needs to be passed to every adb command.

~ ❯ adb -P 5038 start-server
* daemon not running; starting now at tcp:5038
* daemon started successfully
~ ❯ adb -P 5038 pair localhost:39631
Enter pairing code: 405865
* daemon not running; starting now at tcp:5038
ADB server didn't ACK
Full server startup log: /data/data/com.termux/files/usr/tmp/adb.11326.log
Server had pid: 18450
--- adb starting (pid 18450) ---
adb I 11-10 04:53:37 18450 18450 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-10 04:53:37 18450 18450 main.cpp:63] Version 31.0.3-android-tools
adb I 11-10 04:53:37 18450 18450 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-10 04:53:37 18450 18450 main.cpp:63]
adb F 11-10 04:53:38 18450 18450 main.cpp:155] could not install *smartsocket* listener: Address already in use

* failed to start daemon
error: cannot connect to daemon

@agnostic-apollo
Copy link
Member

I guess you are back to #7946 (comment). Does ps show the server running after start-server command?

Did you try restarting phone?

@ghost
Copy link
Author

ghost commented Nov 10, 2021

Did you try restarting phone?

yes i did

@ian4hu
Copy link
Contributor

ian4hu commented Nov 10, 2021

@elwaer-m Try a higher port number.

So try adb -P 5038 start-server, adb -P 5038 pair localhost:, adb -P 5038 connect localhost and adb -P 5038 shell. Or try an even higher port, like 50370. Maybe there is some port restriction, just a guess.

Like 50370

@ghost
Copy link
Author

ghost commented Nov 10, 2021

@ian4hu
i tried with different ports it's still the same

~ ❯ adb -P 50370 start-server
* daemon not running; starting now at tcp:50370
* daemon started successfully
~ ❯ adb -P 50370 pair localhost:45684
Enter pairing code: 465936
* daemon not running; starting now at tcp:50370
ADB server didn't ACK
Full server startup log: /data/data/com.termux/files/usr/tmp/adb.11326.log
Server had pid: 31556
--- adb starting (pid 31556) ---
adb I 11-10 05:24:18 31556 31556 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 11-10 05:24:18 31556 31556 main.cpp:63] Version 31.0.3-android-tools
adb I 11-10 05:24:18 31556 31556 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 11-10 05:24:18 31556 31556 main.cpp:63]
adb F 11-10 05:24:19 31556 31556 main.cpp:155] could not install *smartsocket* listener: Address already in use

* failed to start daemon
error: cannot connect to daemon

@agnostic-apollo
Copy link
Member

Does ps show the server running after start-server command?

Try to answer all asked questions instead of us repeating them.

@ghost
Copy link
Author

ghost commented Nov 10, 2021

@agnostic-apollo

~ ❯ adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
~ ❯ ps
  PID TTY          TIME CMD
 7683 pts/0    00:00:00 bash
 7842 pts/0    00:00:00 ps
~ ❯ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
u0_a1326  6181  5.1  4.4 5790460 124000 ?      S<l   1970   0:06 com.termux
u0_a1326  7683  0.5  0.1 2134008 3948 pts/0    S<s   1970   0:00 /data/data/com.termux/files/usr/bin/bash -l
u0_a1326  7802  0.3  0.1 2201784 4376 ?        S<sl  1970   0:00 adb -L tcp:5037 fork-server server --reply-fd 4
u0_a1326  7909  1.0  0.0 2132076 2088 pts/0    R<+   1970   0:00 ps aux

@agnostic-apollo
Copy link
Member

So if server is successfully started by adb start-server, then why does it say daemon not running; starting now at tcp:* when adb pair is run. 🤔

@agnostic-apollo
Copy link
Member

@elwaer-m Post output for strace adb pair localhost:<port>. Maybe that shows something.

@ghost
Copy link
Author

ghost commented Nov 10, 2021

Post output for strace adb pair localhost:. Maybe that shows something.

the output is too long my browser keeps crashing when i pasting it...

@agnostic-apollo
Copy link
Member

Redirect command or store output in a file and upload that.

@ghost
Copy link
Author

ghost commented Nov 10, 2021

log.txt

@agnostic-apollo
Copy link
Member

That is not full output. Enter pairing code and press enter after it says

write(1, "Enter pairing code: ", 20Enter pairing code: )    = 20
fstat(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(0x88, 0), ...}) = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
read(0, 0x7e8162a400, 1024)             = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
read(0,

@ghost
Copy link
Author

ghost commented Nov 10, 2021

log.txt

@goINTo425
Copy link

I got same errors.
I am also using a Samsung phone. And both android-tools and termux are up-to-date.

@knyipab
Copy link
Contributor

knyipab commented Nov 26, 2021

Same issue was found on my Samsung S21 (android 11, SM-G9910).
My Pixel 4a (android 12) does not have any issue.

@ian4hu
Copy link
Contributor

ian4hu commented Nov 26, 2021

It seems this bug is device-associated/rom-associated. I dont have a Samsung android phone, it would be difficult for me to get the root cause.

@Ingrater
Copy link

Ingrater commented Dec 11, 2021

I'm having the same issue on a Samsung S21. What I'm seeing is the following:

When starting the adb server for the first time, everyting is fine:

adb D 12-11 11:52:50 11446 11446 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 12-11 11:52:50 11446 11446 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 12-11 11:52:50 11446 11446 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 12-11 11:52:50 11446 11446 adb_trace.cpp:187] 
adb D 12-11 11:52:50 11446 11446 adb_client.cpp:346] adb_connect: service: host:start-server
adb D 12-11 11:52:50 11446 11446 adb_client.cpp:155] _adb_connect: host:version
* daemon not running; starting now at tcp:5037
adb D 12-11 11:52:50 11447 11447 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 12-11 11:52:50 11447 11447 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 12-11 11:52:50 11447 11447 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 12-11 11:52:50 11447 11447 adb_trace.cpp:187] 
* daemon started successfully

I can then see that the server is running

u0_a6         7918     1 0 11:38:06 ?     00:00:00 adb -L tcp:5037 fork-server server --reply-fd 4```

I can also see that the server is listeing on 127.0.0.1:5037
```> netstat -tulpn | grep LISTEN
tcp        0      0 127.0.0.1:5037          0.0.0.0:*               LISTEN      -

When I now however run a adb command, adb tries to connect to the server and fails. Then tries to start the server again, which fails beacuse the server is arleady running:

adb D 12-11 11:53:03 11503 11503 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 12-11 11:53:03 11503 11503 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 12-11 11:53:03 11503 11503 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 12-11 11:53:03 11503 11503 adb_trace.cpp:187] 
adb D 12-11 11:53:03 11503 11503 adb_client.cpp:155] _adb_connect: host:version
* daemon not running; starting now at tcp:5037
adb D 12-11 11:53:03 11504 11504 adb_trace.cpp:187] Android Debug Bridge version 1.0.41
adb D 12-11 11:53:03 11504 11504 adb_trace.cpp:187] Version 31.0.3-android-tools
adb D 12-11 11:53:03 11504 11504 adb_trace.cpp:187] Installed as /data/data/com.termux/files/usr/bin/adb
adb D 12-11 11:53:03 11504 11504 adb_trace.cpp:187] 
ADB server didn't ACK
Full server startup log: /data/data/com.termux/files/usr/tmp/adb.10006.log
Server had pid: 11504
--- adb starting (pid 11504) ---
adb I 12-11 11:53:03 11504 11504 main.cpp:63] Android Debug Bridge version 1.0.41
adb I 12-11 11:53:03 11504 11504 main.cpp:63] Version 31.0.3-android-tools
adb I 12-11 11:53:03 11504 11504 main.cpp:63] Installed as /data/data/com.termux/files/usr/bin/adb
adb I 12-11 11:53:03 11504 11504 main.cpp:63] 
adb D 12-11 11:53:03 11504 11504 transport.cpp:844] socketpair: (3,5)
adb D 12-11 11:53:03 11504 11504 transport_local.cpp:233] transport: local client init
adb D 12-11 11:53:03 11504 11506 usb_linux.cpp:609] Created device thread
adb D 12-11 11:53:03 11504 11507 transport_local.cpp:191] transport: client_socket_thread() starting
adb F 12-11 11:53:04 11504 11504 main.cpp:155] could not install *smartsocket* listener: Address already in use

* failed to start daemon
adb: failed to check server version: cannot connect to daemon

I quickly checked with telnet if the server is actually listening on localhost:5037, and it is. So for whatever reason adb cant connect to the tcp port on Samsung phones.

I found a workaround, you can tell adb to use a file as socket instead

>export ADB_SERVER_SOCKET=localfilesystem:$(pwd)/adb_socket
>adb start-server
* daemon started successfully
>adb devices
List of devices attached

@Paranoid-Dev
Copy link

Screenshot_20220125-201357_Termux

127.0.0.1 and 192.168.0.15, the local ip address, works for me used like this
The port should show in the wireless debugging developer options page

@MelleNi
Copy link

MelleNi commented Jan 25, 2022

@Paranoid-Dev
Great, it worked once I did 127.0.0.1:[PORT], where [PORT] is the port as specified in the Wireless debugging interface. Using the local IP did not work for me, somehow.

@nathaneltitane
Copy link

nathaneltitane commented Jan 25, 2022

Screenshot_20220125-201357_Termux

127.0.0.1 and 192.168.0.15, the local ip address, works for me used like this The port should show in the wireless debugging developer options page

So can we do something about the message always showing tcp:5037 regardless of what we specify?

@Paranoid-Dev
Copy link

@nathaneltitane
I wrote in the command the port Android opened for the clientside adb
(46675), and the port 5037 is what the default adb serverside daemon uses.

Some quick googling leads me to the -P option, which as you can see in the screenshot, works with termux as well.
Screenshot_20220126-004001_Settings

@nathaneltitane
Copy link

nathaneltitane commented Feb 1, 2022

back to a very interesting situation: phone died while i was out this weekend, so it powered down.

Attempting to make adb work, using the same exact steps I described last week do not function any more...

Anyone experience dead adb after having it work?

Edit:
Turns out installing rendiix adb binary makes a difference...

Suggestion: @agnostic-apollo @xeffyr could you guys have a look at what differes in your compiled binary and offer a version that runs on all platforms?

@GJoe2
Copy link

GJoe2 commented Feb 6, 2022

I have a similar issue, running adb from pc works
PC

$ adb devices
List of devices attached
[IP]:39143     device

termux-android does not work.
TERMUX

$ adb pair [IP]:40661
Enter pairing code: 344791
* daemon not running; starting now at tcp:5037
* daemon started successfully
* daemon still not running
error: cannot connect to daemon at tcp:5037: Not a data message

@stale
Copy link

stale bot commented Mar 24, 2022

This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix Issue won't be fixed label Mar 24, 2022
@finagolfin finagolfin added not stale and removed wontfix Issue won't be fixed labels Mar 24, 2022
mickaelmendes50 added a commit to mickaelmendes50/optimize_android_tv that referenced this issue Apr 19, 2022
 * Following https://android.googlesource.com/platform/system/netd/+/master/client/FwmarkClient.cpp#33
   and termux/termux-packages#7946
   as reference.
 * Run adb under fakeroot to run it as kernel testing.
   This will fix adb usage for Samsung devices running
   Android 11 and Android 12.

Signed-off-by: Mesquita <mesquita@aospa.co>
@r2k94

This comment was marked as spam.

@megapro17

This comment was marked as resolved.

@termux termux deleted a comment from omarralll Mar 8, 2023
@stale stale bot added the inactive No activity in a certain period of time label May 22, 2023
@stale stale bot removed the inactive No activity in a certain period of time label Jul 18, 2023
@stale stale bot added the inactive No activity in a certain period of time label Oct 1, 2023
@mgood7123
Copy link

does

/bin/adb kill-server
/bin/adb start-server

work for you?

@stale stale bot removed the inactive No activity in a certain period of time label Nov 4, 2023
@mgood7123
Copy link

also try /bin/adb kill-server

then go to developer options and toggle on and off both debugging toggles (via usb and via wifi)

then toggle on debugging wifi
go into it and pair device with pairing code

go to termux and connect via /bin/adb pair [HOST][PORT] [PAIRING CODE]

then, once paired

to back to debugging wifi and close the pairing prompt

look at the section IP address and port underneath Device name

connect via /bin/adb connect [HOST][PORT] with [HOST][PORT] being the one that IP address and port tells you, NOT THE ONE FROM THE PAIRING PROMPT

after connected, you should now see your device under /bin/adb devices and can enter via /bin/adb shell

@stale stale bot added the inactive No activity in a certain period of time label Jan 19, 2024
@customautosys
Copy link

customautosys commented Mar 4, 2024

Hi I also can't connect back to the same device on Termux using adb pair (and also in my proot-distro). No matter what I key in, I get Failed: Unable to start pairing client.

@stale stale bot removed the inactive No activity in a certain period of time label Mar 4, 2024
@Biswa96
Copy link
Member

Biswa96 commented Mar 4, 2024

adb works in termux in my phone since the beginning. Though, it does not work in one step.

  1. adb pair with the pairing code.
  2. restart adb.
  3. adb connect with the localhost and the port show in 'Wireless Debugging' setting.

step 1 and 2 are required for first time only.

@stale stale bot added the inactive No activity in a certain period of time label May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Something is not working properly inactive No activity in a certain period of time
Projects
None yet
Development

No branches or pull requests