35

I've recently upgraded to Android SDK Platform-Tools version 28.0.2. Version information:

$ adb version
Android Debug Bridge version 1.0.40
Version 28.0.2-5303910

When using the adb connect command I now get the following error:

$ adb connect 192.168.1.20
missing port in specification: tcp:192.168.1.20

ADB previously connected to devices using TCP port 5555 by default. I am still able to connect to my device by specifying this port number:

$ adb connect 192.168.1.20:5555
connected to 192.168.1.20:5555

However, this is a minor inconvenience to me as I'm used to typing in just the IP address. Is there any way of telling this version of ADB to use TCP port 5555 by default?

2
  • try this way adb tcpip 5555 then adb connect 192.168.0.242
    – AskNilesh
    Mar 14, 2019 at 8:52
  • @NileshRathod Nope, that command opens up ADB Over Network on a device, where it was previously disabled. Using adb tcpip 5555 with no devices connected returns error: no devices/emulators found. In my case, the development builds of my device are already listening for ADB on that port. Mar 14, 2019 at 8:54

7 Answers 7

20

Update

This bug has now been fixed as of ADB version 1.0.41, which is part of Platform Tools version 29.0.4. The fix for the bug was committed on 31st July 2019:

Restore default port for adb connect.

The default port of 5555 was removed a while back, but the help text was never updated, and other contexts still allow a default port.

Bug: https://issuetracker.google.com/128561172

Inputting adb connect 192.168.1.20 without the trailing port number now results in ADB connecting to the target device, restoring previous behaviour.

Old answer

This would appear to be a bug within ADB, introduced in December 2018 or January 2019. I believe this relates to recent changes to this else statement in socket_spec.cpp.

} else {
    std::string addr(spec.substr(4));
    port_value = -1;

    // FIXME: ParseNetAddress rejects port 0. This currently doesn't hurt, because listening
    //        on an address that isn't 'localhost' is unsupported.
    if (!android::base::ParseNetAddress(addr, &hostname_value, &port_value, serial, error)) {
        return false;
    }

    if (port_value == -1) {
        *error = "missing port in specification: ";
        *error += spec;
        return false;
    }
}

If a port value is not specified, the variable port_value is initialised at -1 and does not change. This value is not altered by android::base::ParseNetAddress either. If the ParseNetAddress check passes then we will always fall into the error-catching statement immediately afterwards.

4
  • 1
    And how to deal with it? Mar 18, 2019 at 11:14
  • 9
    @PonomarenkoOleh The workaround for now is to include the port number e.g. 192.168.1.20:5555. However, this is a bug that is Google's responsibility so we'll need to wait for them to fix it. Mar 18, 2019 at 11:17
  • @PonomarenkoOleh However, you can also star the bug report so that it gains the attention of the developers sooner. Mar 18, 2019 at 11:23
  • I'm running version 1.0.41 (Raspbian/Debian version) and still getting the exact same error.
    – RCross
    Oct 4, 2022 at 15:12
13

I can able to connect my android phone by adding a port number in the postfix place.

For example,

$ adb kill-server

$ adb connect 192.168.1.20:5555

Directly it could not able to connect, it was giving me the above error.

NOTE: Port number is compulsory to apply, maybe your port number is currently different so please find that and then try to connect again.

2
  • 1
    But this workaround was already mentioned in the question itself? Quote: "I am still able to connect to my device by specifying this port number" May 13, 2019 at 10:59
  • Specifying 5555 port, I was able to connect. Thanks
    – Anas Azeem
    Jul 11, 2019 at 8:34
7
$ adb kill-server
$ adb connect 192.168.1.20

Just kill the adb server and connect normally. Default port (5555) is restored when server is restarted.

3
  • Maybe works for people who get this error sometimes, but not always. Worked for me on macos Mar 23, 2019 at 23:31
  • MacOS 10.14 Mojave here. Does your version of ADB match when you use adb version? Mar 24, 2019 at 11:38
  • Yup, adb version is same. MacOS version is 10.14.4 Apr 20, 2019 at 14:57
3

I stumbled upon this thread when I searched for a similar problem I had with the Visual Studio emulator for Android. When you try to drag & drop an *.apk file for installing, it gives you the same error

I fixed it by downloading the latest -working- platform-tools v27.0.1 from google and replacing the content in the android SDK folder (in my case %LOCALAPPDATA%\Android\Sdk).

I know, it's not the best solution, but as long as google didn't release a fixed adb version (still not in v29.02), I can live with it.

1
  • Wow, thanks for adding your answer as well (I stumbled here from the same issue). I haven't any idea how you sorted out that solution, but it worked for me as well. Sep 22, 2019 at 6:39
2

There's another workaround, with credit to this unknown person in the Google issue thread. Create a custom alias that automatically adds the default port number to the IP address.

For Linux & MacOS, in ~/.bashrc or ~/.bash_aliases:

function adbc() {
   adb connect $1:5555
}

Then connect using command

$ adbc 192.168.1.20

For Windows users:

Put this in adbc.bat anywhere in your PATH

@echo off
adb connect %1:5555

Then connect using command

> adbc 192.168.1.20
1

Just flagged this on an AndroidThings device,

had to swap

 adb connect Android.local

with

 adb connect Android.local:5555
1
  • That's very interesting how it's happening with Android's own internal ADB as well, though it would make sense if it's sharing the same code base. May 29, 2019 at 15:20
1

Setting the port for the Android device will solve the problem.

Here is how:

  1. Connect the Android device with USB to your computer (Linux, MacOs or whatever) with adb installed.
  2. Execute adb tcpip <port_number>. This will set the device in TCP mode with port , although the device may not be currently using the Ethernet or WiFi. This will make the port_value not equals -1 or undefined.
  3. disconnect the Android device from your computer through USB.
  4. adb connect <IP address>:<port number> This should connect the device. The device should show up in the result of adb devices.

It worked for me when I "adb over Ethernet" and "adb over wifi" with my Pixel 3 XL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.