16

I've already used this commands before to set ADB to listen on TCP/IP, but this time I'm stunned. The problem is that the error it's throwing just makes no sense:

$ adb tcpip 5555
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
error: device not found

In fact even trying to put it in USB mode doesn't work either, with same error:

$ adb usb
error: device not found

Just for the info, the adb help says that:

adb usb                      - restarts the adbd daemon listening on USB
adb tcpip <port>             - restarts the adbd daemon listening on TCP on the specified port

I've made no changes in Android SDK (no updates). Any help would be appreciated.

m0skit0
  • 25,268
  • 11
  • 79
  • 127

7 Answers7

34

The issue was that I had to have an Android device connected (same device or another device) by USB to be able to execute

$ adb tcpip 5555
restarting in TCP mode port: 5555

Then I can just unplug this USB device and connect to the other devices on the LAN over TCP.

Just makes no sense at all.

Renjith K N
  • 2,613
  • 2
  • 31
  • 53
m0skit0
  • 25,268
  • 11
  • 79
  • 127
  • 1
    makes perfect sense. if you know what 'adb tcpip' command actually does. it tries to reconfigure and restart the adbd daemon on the device and it needs a functional connection to the device to do that – Alex P. Feb 15 '13 at 18:03
  • 12
    @AlexP. Well... no. **`adb tcpip` does not initialize anything on the device**. And again, **I'm not even connecting to the device connected by USB**. It's other devices I'm connecting to. Still makes no sense. – m0skit0 Feb 15 '13 at 18:34
  • uh. Which part of the following line of adb help "adb tcpip - restarts the adbd daemon listening on TCP on the specified port" do you not understand? – Alex P. Feb 15 '13 at 18:58
  • 2
    it is talking about "adbd daemon" - the daemon running on the device. – Alex P. Feb 15 '13 at 19:13
  • Thanks for the clarification. Even if so, the devices have a functional connection through TCP. – m0skit0 Feb 15 '13 at 19:32
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/24590/discussion-between-m0skit0-and-alex-p) – m0skit0 Feb 15 '13 at 19:34
  • As as Alex P. Says - you definitely need to have a device connected via usb first - as this is what adb defaults to – Aiden Strydom Apr 02 '13 at 14:10
  • @AidenStrydom No. Looks like the ADB was already configured to listen by TCP. See the chat discussion for more details. – m0skit0 Apr 02 '13 at 15:44
  • 1
    Just for the record, [this](http://stackoverflow.com/questions/2604727/how-can-i-connect-to-android-with-adb-over-tcp) is a good answer. You must be rooted if you want to run this from the device. Otherwise you need to be connected by USB. – JonasVautherin Jul 17 '14 at 08:44
  • @JonesV Device is rooted. My problem was, if you read the answer, that adb won't let me connect to a device by TCP unless you plug another device by USB. I suppose this is needed to start the ADB server or something... For me it's a bug. And btw linked answer has -16 votes... – m0skit0 Jul 17 '14 at 09:01
  • @JonesV Well that didn't work as I explained already. If you don't plug a device by USB, adb by TCP/IP won't work, no matter it adb USB worked before. – m0skit0 Jul 18 '14 at 11:11
  • It works for me on different devices, using the "from the device" commands. – JonasVautherin Jul 18 '14 at 11:41
  • 1
    @m0skit0 I know it's been a while, but it's clear to me after reading it all that you didn't understand the heart of the issue back then. **You can get ADB over network without ever attaching an usb cable**, as long as you have root access on the device itself. For this you have to issue `setprop service.adb.tcp.port 5555` on your device's terminal **as root** (i.e. issue `su` first), then restart `adbd` (ADB Daemon) as described in [this answer](http://stackoverflow.com/a/3623727/3258851). On some devices [there's even a setting](http://i.stack.imgur.com/8euGG.png) to make this easier. – Marc.2377 Jul 05 '16 at 20:06
  • @Marc.2377 Note that I'm the one asking the question. Anyway my question lacks an important detail: ADB over TCP was already turned on on all the devices on the LAN. The problem is that the PC won't connect to them until I plug an Android device by USB. Then it will connect by TCP. – m0skit0 Jul 13 '16 at 08:56
  • 1
    @m0skit0 Hey, thanks for answering. Just to be absolutely clear: by "device" you mean the *smartphone*, right? When I said "on your device's terminal", it's the "android terminal emulator" that I'm talking about. – Marc.2377 Jul 13 '16 at 09:04
  • 4
    Just read the conversation, and I agree with @m0skit0 - this makes no sense at all. It's easy to prove: 1) Connect AndroidDeviceA to PC via USB; 2) Run `adb tcpip 5555` which will succeed `restarting in TCP mode port: 5555`; 3) Unplug AndroidDeviceA; 4) Connect AndroidDeviceB to PC via wireless network by executing `adb connect 192.168.x.x:5555`, which will succeed saying `connected to 192.168.x.x:5555`. Obviously we can come to the conclusion that AndroidDeviceA via USB is useless, no device daemon operation needed, since our goal is to connect to AndroidDeviceB via wireless network anyway. – Jing Li Oct 28 '17 at 19:43
  • 1
    It's just a bad design / bug of Android `adb` - which leads to this nonsense operation. Android is a cool, but `adb` is indeed poorly designed. – Jing Li Oct 28 '17 at 19:46
  • Simply, if everytime I need to use an usb, to establish a connection over LAN/Wi-Fi, it doesn't make sense. – hkchakladar Nov 12 '19 at 17:54
  • 1
    Agree with @m0skit0 that this is weird behavior. Using Visual Studio 2022, I could not connect via wifi to an nVIDIA Shield (Android TV device). I plugged a Kindle Fire into my dev computer via a USB cable, and I can now connect to my nVIDIA shield via wifi. Literally doesn't matter what Android based device, but I have not plug something into my dev computer to enable wifi debugging on an Android TV. – Brett Woodard Aug 25 '23 at 19:55
  • @BrettWoodard As you can see 10 years have passed and... Still the same! – m0skit0 Aug 25 '23 at 21:26
5

Ensure your device is set for Debugging under Developer Tools, then on your host computer's command-line, type:

$ adb tcpip 5555                  - restarts the adbd daemon listening on TCP on the specified port (typically 5555)

restarting in TCP mode port: 5555

If you get "error: device not found", you need to temporarily connect an Android by USB cable. (This doesn't even need to be the same device, and doesn't need to remain connected)

Then, connect to the Android device by IP address. (Ensure your Android is connected to your local network then to find the IP address, click on the wifi network connection to see connection details.)

$ adb connect 192.168.0.10        - connects over network to remote device IP (replace 192.168.0.10 with your Android device's IP address)

connected to 192.168.0.10:5555

Depending on your connection, this could take a minute or so to establish the first time.

To switch back to your USB connection, type:

$ adb usb                         - restarts the adbd daemon listening on USB

Additional Notes:

  • You do not need root access for this to work.
  • You may need to open port (5555) in your firewall.
  • You can use "ping " to ensure your host can find the device on the network
AlaskaJohn
  • 119
  • 1
  • 4
  • 2
    *"you need to temporarily connect an Android by USB cable"* Correct, this is what I stated in my answer (despite @AlexP. being stubborn about it). – m0skit0 Jun 10 '14 at 10:26
3

What you probably want is:

 connect <host>[:<port>]       - connect to a device via TCP/IP
                                 Port 5555 is used by default if no port number is specified.

so:

$ adb connect 192.168.1.38
Tobia Zambon
  • 7,479
  • 3
  • 37
  • 69
1

adb usb and adb tcpip <port> commands control the transport mode of the adbd daemon running on the device. In order to change the mode the current transport has to be functional. In your case the adbd is running in USB mode - so you have to connect the USB cable in order for the mode change request to reach the deamon.

If you want to avoid having to connect USB just to enable the TCPIP transport - you can either change the default settings or switch it manually from a terminal emulator on the device itself.

Alex P.
  • 30,437
  • 17
  • 118
  • 169
  • I did not need to connect the device by USB to configure he daemon and still connected by TCP. I did not configure anything on it (except enabling debugging) either. – m0skit0 Feb 15 '13 at 19:59
  • I can only answer the questions you have asked. You can not get proper answer without asking the proper question first. In my answer I just explained why 'adb usb' and 'adb tcpip' commands had failed for you. – Alex P. Feb 15 '13 at 20:08
  • 1
    How to stop "adbd daemon running on the device"? – Rahul Matte Jan 27 '15 at 12:20
  • 3
    @AlexP. are you aware of a way to do this without connecting USB? It's really annoying to plug my phone in after every restart just to run `adb tcpip`. (I don't have root.) – TWiStErRob Apr 05 '16 at 21:08
0

I also encountered this problem and tried to solve them in a week. Finally it is solved within minutes when I change the setting in my device to allow the debugging when charging. I also ensure that the allow usb debugging enabled because sometimes when you choose to allow debugging when charging, the allow usb debugging will be disabled.

after that, I try the adb tcpip 5555 again and voila!!! no more no emulators... kinda message. I then connect using adb connect 'ip address':5555 and it works like charm.

Simson
  • 3,373
  • 2
  • 24
  • 38
0

I think the major issue here is if adb tcpip 5555 <-- this command is a prerequisite before running, adb connect 'ip address':5555

If the 2 commands are independent, it makes sense, otherwise it is a stupid design.

mcdull
  • 1
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 08 '23 at 06:33
-2

After connect phone with usb, choose option at phone "charging only".

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 11 '22 at 13:48