By JDM


2010-04-09 02:18:00 8 Comments

I am attempting to debug an application on a Motorola Droid, but I am having some difficulty connecting to the device via USB. My development server is a Windows 7 64-bit VM running in Hyper-V, and so I cannot connect directly via USB in the guest or from the host.

I installed a couple of different USB-over-TCP solutions, but the connection appears to have issues since the ADB monitor reports "devicemonitor failed to start monitoring" repeatedly. Is there a way to connect directly from the client on the development machine to the daemon on the device using the network instead of the USB connection or possibly another viable options?

30 comments

@eleven 2018-10-16 11:48:43

Bash util function:

function adb-connect-to-wifi {
    ip="$(adb shell ip route | awk '{print $9}')"
    port=5555
    adb tcpip ${port}
    adb connect ${ip}:${port}
}

@MapleLover 2013-04-14 21:36:50

Assume you saved adb path into your Windows environment path

  1. Activate debug mode in Android

  2. Connect to PC via USB

  3. Open command prompt type: adb tcpip 5555

  4. Disconnect your tablet or smartphone from pc

  5. Open command prompt type: adb connect IPADDRESS (IPADDRESS is the DHCP/IP address of your tablet or smartphone, which you can find by Wi-Fi -> current connected network)

Now in command prompt you should see the result like: connected to xxx.xxx.xxx.xxx:5555

@Zibri 2015-03-29 14:28:51

This is the right procedure.

@Zoe 2017-06-09 14:58:22

From a computer on a non-rooted device

(Note that this can be done using a rooted device as well, but you can use a shell on a rooted device which doesn't require a USB connection)

Firstly, open command prompt (CMD). If you use Android Studio or IntelliJ there is a console included in there you can use.

If possible, open the SDK location, right click, and press "start command prompt here". Not all have this option so you have to do this (/these) commands as well:

Change the drive (if applicable)

D: 

And access the sdk and platform tools. Replace this path with your SDK location:

D:/sdk/path/here/platform-tools

Now you have access to the Android debug bridge.

Now, with the device connected to the computer, do:

adb tcpip <port> 
adb connect <ip>:<port>

Where is the port you want to connect to (default is 5555) and is the IP of the device you want to connect to.

Please note: 5555 is the default port and just writing the IP address connects it. If you use a custom port you can at least improve the security a bit. USB debugging over wifi can be abused, but only if the device is connected to the computer who wants to abuse the device. Using a non-default port at least makes it a bit harder to connect.

If you use a custom port, make sure to add it after the IP. Writing no port connects to 5555 and if you didn't use that the connection will fail.

You can find the IP address of a device in two ways:

  • Depending on your device, the exact names may vary. Open settings and go to About device -> Status -> IP address

  • Use ADB to get the IP

From the console, do:

adb shell ip -f inet addr show wlan0

And once you are finished with the connection, you can disconnect the device from your computer by doing:

adb disconnect <ip>:<port>

Or no IP to disconnect all devices. If you used a custom port, you must specify which port to disconnect from. The default is 5555 here as well.

To disable the port (if that is something you want to do) you do this command with the device connected:

adb usb

Or you can restart the device to remove the tcpip connection

From a computer on a rooted device

Firstly, you need access to the shell. You either connect the device using a usb cable and use adb shell or download an app from Google Play, FDroid, or some other source.

Then you do:

su
setprop service.adb.tcp.port <port>
stop adbd
start adbd

And to connect the device, you do as in the non-rooted version by doing adb connect <ip>:<port>.

And if you want to disable the port and go back to USB listening:

setprop service.adb.tcp.port -1
stop adbd
start adbd

You can also use an Android Studio plugin to do it for you (don't remember the name right now), and for rooted users there's also the option of downloading an Android app to set up the phone connection (adb connect is probably still required).

Some phones have a setting in developer options (this applies to some unrooted phones, though probably some rooted phones too) that allows for toggling ADB over wifi from the device itself without root or a computer connection to start it. Though there are few phones that have that

@Michael 2017-06-27 00:38:20

adb shell ip -f inet addr show wlan0 Is the IP address and port support to be substituted in somewhere therE?

@Zoe 2017-07-25 10:19:01

not in that line. That is the shell-way to get the IP. Nothing in there should be replaced in that line

@Abdul Wasae 2017-05-15 06:54:38

If you want to be able to do it on a button click then:

  1. In Android Studio -> Settings/Preferences -> Plugins -> Browse Repositories
  2. Search 'ADB wifi'
  3. Install and restart android studio
  4. Connect your device (with USB Debugging enabled) to your computer with USB (you will need to do this just once per session)
  5. Tools -> Android -> ADB WIFI -> ADB USB TO WIFI (Or use the key combination mentioned. For MacOS: ctrl + shift + w)

Note: If it did not work:

  1. Your wifi router firewall may be blocking the connection.
  2. ABD may not be installed on your computer.

@Raghav Thakkar 2015-10-25 19:49:34

For PC users:

Step 1:
You have to enable Developer options in your Android phone.
You can enable Developer options using this way.
• Open Settings> About> Software Information> More.
• Then tap “Build number” seven times to enable Developer options.
• Go back to Settings menu and now you'll be able to see “Developer options” there.
• Tap it and turn on USB Debugging from the menu on the next screen.

Step 2:

Open cmd and type adb.
if you find that adb is not valid command then you have to add a path to the environment variable.

•First go to you SDK installed folder
Follow this path and this path is just for an example. D:\softwares\Development\Andoird\SDK\sdk\platform-tools\; D:\softwares\Development\Andoird\SDK\sdk\tools;
• Now search on windows system advanced setting

enter image description here

Open the Environment variable.

enter image description here

then open path and paste the following path this is an example.
You SDK path is different from mine please use yours. D:\softwares\Development\Andoird\SDK\sdk\platform-tools\;
D:\softwares\Development\Andoird\SDK\sdk\tools;

enter image description here

Step 3:

Open cmd and type adb. if you still see that adb is not valid command then your path has not set properly follow above steps.

enter image description here

Now you can connect your android phone to PC.

Open cmd and type adb devices and you can see your device. Find you phone ip address.

enter image description here

Type:- adb tcpip 5555

enter image description here

Get the IP address of your phone

adb shell netcfg

Now,

adb connect "IP address of your phone"

Now run your android project and if not see you device then type again adb connect IP address of your phone

enter image description here

enter image description here

For Linux and MAC User:

Step 1: open terminal and install adb using

sudo apt-get install android-tools-adb android-tools-fastboot

Connect your phone via USB cable to PC. Type following command in terminal

adb tcpip 5555

Using adb, connect your android phone ip address.

Remove your phone.

@Innocent 2018-02-17 09:17:37

thank you very much

@Joolah 2016-06-07 01:45:04

First you must connect your device via USB

Then connect your device to WIFI and get the IP address. While still connect via usb type this in command line or via Android Studio Terminal

adb tcpip 5555
adb connect <device IP>:5555

You will see these messages:

restarting in TCP mode port: 5555
connected to 172.11.0.16:5555

Now remove the USB cable and you will still see your logcat as normal

Done. Enjoy

@Paulo Mendonça 2016-06-16 14:39:55

thank you! i've been searching for this a long time ;)

@Tim Scott 2016-08-28 23:35:48

This worked. However. After performing these steps, I can no longer switch back to the emulator. Suggestions?

@Joolah 2016-08-30 14:02:49

You need to restart your adb with: <adb kill-server> and then <adb start-server>

@noman404 2016-05-26 04:31:57

You Need to do following things:

  • First, Add ADB to your environment path.
  • From your CLI type this command adb connect YOUR_DEVICE_IP:PORT_NUMBER (example adb connect 192.168.100.100:5555)

@Isuru 2017-08-20 11:16:07

This worked for me.

@Brian 2010-09-02 03:59:44

Manual Process

From your device, if it is rooted

According to a post on xda-developers, you can enable ADB over Wi-Fi from the device with the commands:

su
setprop service.adb.tcp.port 5555
stop adbd
start adbd

And you can disable it and return ADB to listening on USB with

setprop service.adb.tcp.port -1
stop adbd
start adbd

From a computer, if you have USB access already (no root required)

It is even easier to switch to using Wi-Fi, if you already have USB. From a command line on the computer that has the device connected via USB, issue the commands

adb tcpip 5555
adb connect 192.168.0.101:5555

Be sure to replace 192.168.0.101 with the IP address that is actually assigned to your device.

You can find the IP address of a tablet in two ways:

Manual IP Discovery:

Go into Android's WiFi settings, click the menu button in the action bar (the vertical ellipsis), hit Advanced and see the IP address at the bottom of the screen.

Use ADB to discover IP:

Execute the following command via adb:

adb shell ip -f inet addr show wlan0

To tell the ADB daemon return to listening over USB

adb usb

Apps to automate the process

There are also several apps on Google Play that automate this process. A quick search suggests adbWireless, WiFi ADB and ADB WiFi. All of these require root access, but adbWireless requires fewer permissions.

@J J 2011-06-11 04:28:48

Do you need root access to do this? I seem to be able to run the commands using terminal, but it doesn't actually seem to work...

@Kingsolmn 2011-06-11 19:38:37

@ J J - Unfortunately, yes. Root required.

@yingted 2011-10-08 01:55:02

Also, check your firewall. I had to reconfigure my firewall.

@Ridcully 2012-02-22 06:58:35

For the second solution (adb tcipip 5555 and adb connect ... there's no root necessary.

@John 2012-07-13 21:55:37

there are small free apps on the market that launch adb into tcpip mode.

@soulseekah 2012-10-22 09:03:55

adb tcpip <port> still requires either ro.kernel.qemu property to be set (running in emulator mode), ro.secure to be 0 (i.e. a rooted device), or ro.debuggable and service.adb.root to be set to 1. adbd simply won't open a TCP/IP connection if none of the above is met. See netmite.com/android/mydroid/system/core/adb/adb.c adb_main parts about the secure variable. adbd on my unrooted 2.3.7 Android does not enter TCP/IP mode at all.

@Rich 2012-10-23 12:42:03

One additional comment: If you're using Windows, you'll need to change the "adb connect 192.168.0.101:5555" line to "adb connect 192.168.0.101". Also, don't close the terminal window, just leave it alone (at least, for Windows).

@Mohammed Subhi Sheikh Quroush 2012-12-31 05:41:18

very good method

@Rohit Sangal 2013-01-16 06:02:51

Thanks for the very good example, can you please tell me the reqiurement of the device to be rooted, is it mandatory.

@Grzegorz D. 2013-05-30 20:43:30

Great! Second solution really doesn't require root!

@lapo 2013-06-17 15:49:20

BTW: the first app (the one that "requires fewer permissions") seems to exist no more.

@Brian 2013-06-17 15:59:54

@lapo Here is a link to an F-Droid archive of the app f-droid.org/repository/browse/?fdid=siir.es.adbWireless

@KrisWebDev 2013-08-18 07:17:00

You can use restart instead of stop and start

@KrisWebDev 2013-08-18 07:33:09

Note that adb server locates emulator/device instances (ie adbd aka the daemon) by scanning odd-numbered ports in the range 5555 to 5585. So use ODD numbers in that range for your TCP ports otherwise you will have to manually connect, which is a pain (doable but not recommended: adb connect <ip>:<port>).

@Marc M. 2013-08-28 01:08:51

Sweeeeeeeeet!!!

@Jay Bobzin 2014-05-10 16:40:10

Here's a couple aliases I whipped up to automate the second solution. However I haven't been able to get it to work unrooted. alias adbip='adb shell ip -f inet addr show wlan0 | sed -En "s/.*inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*/\1/p"' alias adbwifi='ADB_IP=adbip; adb tcpip 5555 && adb connect $ADB_IP'

@CoatedMoose 2014-05-27 14:39:25

@JayBobzin, your aliases didn't quite work for me, I had to change 'ADB_IP=adbip; ...' to 'ADB_IP=$(ADB_IP); ...'. Could be a bash thing.

@Philipp Rieber 2015-02-09 20:14:47

Worked on my Mac only when leaving out the port number when connecting: "adb connect 192.168.0.101" – no rooting necessary. Great!

@Bron Davies 2015-04-23 14:18:20

All of this is already on developer.android.com/tools/help/adb.html#wireless make sure you are on the same subnet too. 196.168.0.* usually cannot access 196.168.1.* ;)

@JM Lord 2015-06-15 15:06:56

I confirm with Philipp : for the non-root option, it was necessary to leave out the port number - in my case using Windows. "adb tcpip 5555" + "adb connect 192.168.0.101"

@Sayka 2015-09-05 14:24:34

You're a hero.. By the way, i did it without root.. :-) Thank you

@mr5 2015-09-18 05:38:54

For some reason, when I'm trying to execute adb tcpip 5555, I always need to: re plug the USB; switch device mode, turn the WiFi on and off again; restart adb. Repeat those until it work. Don't wait if the adb tcpip 5555 command hangs, it just doesn't work. Good answer btw.

@IronBlossom 2015-10-12 10:08:50

Great!! One question can I add multiple devices through tcpip?

@azizbekian 2015-10-21 05:19:02

Getting this error on Asus Zenfone 2: unable to connect to 192.168.0.173:5555: cannot connect to 192.168.0.173:5555: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060) Reasons? Workaround?

@Brut3 Forc3 2015-12-03 16:10:26

If adb service runs at port 5037 then why does it locate devices in the range 5555 to 5585 ? Can anyone please explain me

@Script Kitty 2016-01-05 03:38:14

Thanks so much! I was being dumb and my phone was connected to a different wifi network than my computer. But got it working now

@aleksamarkoni 2016-01-05 17:48:04

I would just like to add that before you type adb connect <ip-address>:<port> you should take out the usb cable, because when you connect over wifi you will start authorization dialog, and because you are authorized over the cable, you will not be able to authorize wifi connection also.

@Josh 2016-08-31 09:40:52

This is one of the most useful answers in SO ever. I am a heavy duty developer and usb cables would fail after a few months, and my device would no longer be detected by android studio. I just connected my device with a good usb cable once, ran tcpip 5555, and then connect command ...afterwards, I used no cable and used only the adb connect... command to test my apps over wifi. SWEET!

@Diaa Saada 2018-07-31 09:07:28

can I use device public IP (4G) e.g. adb -d connect 85.36.1.184:5555 how can I aceive such thing after I open the port ?

@TuomasG 2016-03-31 10:57:50

One additional note (learned the hard way): You should not have your company VPN-connection active at the same time...

@Eddy 2016-03-11 02:34:40

STEP 1.

Make sure both your adb host computer and Android device are on the same Wifi network.

STEP 2.

Connect the Android device with the computer using your USB cable. As soon as you do that, your host computer will detect your device and adb will start running in the USB mode on the computer. You can check the attached devices with adb devices whereas ensure that adb is running in the USB mode by executing adb usb.

$ adb usb
restarting in USB mode
$ adb devices
List of devices attached
ZX1D63HX9R  device


STEP 3.

Restart adb in tcpip mode with this command:

$ adb tcpip 5556
restarting in TCP mode port: 5556


STEP 4.

Find out the IP address of the Android device. There are several ways to do that:

  • WAY: 1 Go to Settings -> About phone/tablet -> Status -> IP address.
  • WAY: 2 Go to the list of Wi-fi networks available. The one to which you’re connected, tap on that and get to know your IP.
  • WAY: 3 Try $ adb shell netcfg.

Now that you know the IP address of your device, connect your adb host to it.

$ adb connect 192.168.0.102:5556
already connected to 192.168.0.102:5556
$ adb devices
List of devices attached
ZX1D63HX9R  device
192.168.0.102:5556  device


STEP 5.

Remove the USB cable and you should be connected to your device. If you don’t see it in adb devices then just reconnect using the previous step’s command:

$ adb connect 192.168.0.102:5556
connected to 192.168.0.102:5556
$ adb devices
List of devices attached
192.168.0.102:5556  device

Either you’re good to go now or you’ll need to kill your adb server by executing adb kill-server and go through all the steps again once more.

Hope that helps!


Reference:

@ahsan.dev 2016-04-13 15:11:24

Additionally, you can get the IP of your device with this script on Unix: adb shell ip -f inet addr show wlan0 | grep inet | echo -n $(grep -Eo '[0-9\.\/]') | echo -n $(grep -Eo '^[^\/]*') | sed 's/ //g'

@iSrinivasan27 2016-04-25 12:36:01

@Eddy One doubt that both system and mobile/Tablet must connected via WiFi or else system connected through LAN and tablet connected using of WIFi router of same network. Please Clarify it

@Eddy 2016-04-26 02:33:36

@i-Droid I don't know why both have to connect in the same network. maybe ADB use special net routing protocol. I have no idea and no deep research about it. If you have interest in it, welcome to clarify it and share it with me, thanks!

@9re 2015-11-19 16:03:50

adb can communicate with adb server over tcp socket. you can verify this by telnet.

$ telnet 127.0.0.1 5037
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
000chost:version
OKAY00040020

generally, command has the format %04x%s with <message.length><msg> the following is the ruby command witch sends adb command cmd against tcp socket socket

def send_to_adb(socket, cmd)
  socket.printf("%04x%s", cmd.length, cmd)
end

the first example sends the command host:version which length is 12(000c in hex). you can enjoy more exciting command like framebuffer: which takes screenshot from framebuffer as you can guess from its name.

@Ian Ni-Lewis 2016-01-18 17:43:35

This is cool info but it doesn't address the question. The adb server is host-side, and the question is asking how to communicate with the device wirelessly. (The reason adb server exists is to multiplex adb host sessions over a single host-to-device transport, usually a USB endpoint.)

@Pedro Vicente Gómez Sánchez 2015-10-20 18:01:08

If you want to easily connect your device to run, debug or deploy your Android apps over WiFi you can use an open source IntelliJ Plugin I've developed. Here is the code and here the plugin ready to be used.

The usage is quite simple. Here you have a gif:

enter image description here

@rostamiani 2015-10-21 06:44:52

This error occures: "'adb'command not found. Review your Android SDK installation.

@Pedro Vicente Gómez Sánchez 2015-10-21 19:36:15

You have to declare a environment variable with name ANDROID_HOME. But I have a PR pending to review to avoid this. With the version 1.2 I'm going to publish next week the plugin will work just with IntelliJ installed :)

@powder366 2015-10-27 19:20:55

Im using mac, don't see an icon in AS? Do I need to do something manual first?

@Pedro Vicente Gómez Sánchez 2015-11-02 20:03:18

I've already published a new version where the ANDROID_HOME environment variable is not needed anymore. @powder366 you need to install the plugin from the IntelliJ plugins store of installing it manually. All the instructions needed to install and use the plugin are in the project readme, take a look github.com/pedrovgs/AndroidWiFiADB

@powder366 2015-11-02 20:19:40

@PedroVicenteGómezSánchez Thanks. I picked the wrong plugin, there exist another plugin with similar name...

@Chris623 2016-08-18 16:18:22

this plugin is really great and easy to use :)

@RaRa 2017-06-14 11:05:28

moto g play connect successfully, but when remove usb, both the connection terminate, FYI- i am already connected with other device.

@Sayka 2015-09-08 09:56:26

I've found a convenient method that i would like to share.

For Windows

Having USB Access Once

No root required

Connect your phone and pc to a hotspot or run portable hotspot from your phone and connect your pc to it.

Get the ip of your phone as prescribed by brian (Wont need if you're making hotspot from your phone)

adb shell ip -f inet addr show wlan0

Open Notepad

Write these

@echo off
cd C:\android\android-sdk\platform-tools
adb tcpip 5555
adb connect 192.168.43.1:5555

Change the location given above to where your pc contains the abd.exe file

Change the ip to your phone ip.

Note : The IP given above is the basic IP of an android device when it makes a hotspot. If you are connecting to a wifi network and if your device's IP keeps on changing while connecting to a hotspot every time, you can make it static by configuring within the wifi settings. Google it.

Now save the file as ABD_Connect.bat (MS-DOS batch file).

Save it somewhere and refer a shortcut to Desktop or Start button.

Connect through USB once, and try running some application. After that whenever you want to connect wirelessly, double click the shortcut.

Note : Sometimes you need to open the shortcut each time you debug the application. So making a shortcut key for the shortcut in desktop will be more convenient. I've made a shortcut key like Ctrl+Alt+S. So whenever i wish to debug, i'll press Shift+F9 and Ctrl+Alt+S

Note : If you find device=null error on cmd window, check your IP, it might have changed.

@rinkesh 2013-01-29 06:28:45

To connect your tablet using TCP port. Make sure your system and device is connected to same network.

  1. Open console cmd.exe
  2. Type adb tcpip 5555
  3. Go to System -> Development option -> USB debugging --> Uncheck it for TCPIP connection
  4. Type adb connect 192.168.1.2 this is your device IP address
  5. Connected to 192.168.1.2

Connected using port forward Try to do port forwarding,

adb forward tcp:<PC port> tcp:<device port>

like:

adb forward tcp:5555 tcp:5555.

C:\Users\abc>adb forward tcp:7612 tcp:7612

C:\Users\abc>adb tcpip 7612 restarting in TCP mode port: 7612

C:\Users\abc>adb connect 10.0.0.1:7612

connected to 10.0.0.1:7612

If you get message error: device not found connect a usb device to system then follow same procedure.
for a rooted device

setprop service.adb.tcp.port 5555
stop adbd
start adbd

@Peter Rader 2014-08-01 18:31:55

In console write su first to get a rooted-console.

@beguinner 2015-01-05 22:50:13

Steps :

  1. su -- To switch to super user.
  2. setprop service.adb.tcp.port 5555 - To specify the tcp Port - 5555 is the port number here
  3. stop adbd - To stop the adbd service.
  4. start adbd - To start adbd service.

this works perfectly with ssh from my windows PC

I try to do this on the boot on my cyanogen mobile or launch this with plink. With plink I can't launch shell with su right ... sudo or su command not works. On boot I don't know how it's works! My shell program works from ssh with su -c "sh /storage/sdcard1/start_adb.sh" with the last 3 commands (without su --)

Thanks

@Ribin Haridas 2015-01-22 08:31:49

  1. Connect device via USB and make sure debugging is working, then run:

    adb tcpip 5555
    adb connect <DEVICE_IP_ADDRESS>:5555
    
  2. Disconnect USB and proceed with wireless debugging.

  3. When you're done and want to switch back to USB debugging, run:

    adb -s <DEVICE_IP_ADDRESS>:5555
    

To find the IP address of your device, go to Settings > Wi-Fi > Advanced > IP Address on your device or run adb shell netcfg.

No root required. Only one device can be debugged at a time.

See this XDA post.

The adb command is located in the platform-tools folder of the Android SDK.

@andreszs 2015-02-16 18:53:49

Actually, you can connect many devices at a time, if you follow the right order. Just set the tcpip to 5555 individually for each phone, then issue the connect command for each phone and voilá, they are all connected to adb.

@Aron Lorincz 2015-07-21 13:33:54

Debugging is a bit slower if my phone is connected this way. Also, sometimes it falls asleep and that causes an immediate disconnect.

@vhamon 2018-07-24 09:49:20

On some devices, the delay between adb tcpip command and adb connect command has to be very low otherwise it does not work. Also, for me it worked by doing adb tcpip 5555 && adb connect <DEVICE_IP_ADDRESS>:5555

@Wernight 2014-11-10 10:19:32

Here's an extension to Brian's answer using Bluetooth:

  1. On Linux, use Blueman to share PC internet with your device via Bluetooth:

    $ sudo apt-get install blueman
    $ blueman-manager
    Pair them: Search devices after enabling Bluetooth
    on your phone and making it visible
    $ blueman-services
    Network > [X] Network Access Point (NAP)
    Your Phone > Settings > Bluetooth > Paired Device > [X] Internet access
    
  2. Use the Bluetooth network for ADB commands:

    $ adb tcpip 5555
    $ adb connect $(adb shell ip -f inet addr show bt-pan | egrep -o '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n1):5555
    

Once done to return to USB mode:

$ adb disconnect
$ adb usb

Note: Bluetooth 3.0 and 4.0 can go up to 24 Mbit/s.

@JDM 2010-04-17 20:39:35

I ended up getting the Eltima USB to Ethernet software working after finally giving up on the possibility of a direct to device connection over TCP. I have pretty much decided that it is not possible to connect to a device across the network only an emulator.

@JDM 2012-03-02 23:10:31

at the time it was the only solution

@Pathfinder 2018-01-20 15:15:53

@Ron 2011-02-17 21:45:46

You can also use SSH local port forwarding. But it still involves a USB cable. Connect your phone using USB to a computer (host) with an sshd running. On a remote (guest) pc start an SSH client capable of portforwarding/tunneling. Example:

plink -L 5037:localhost:5037 <host_IP_address>

I use this construction to connect my device to a virtual machine. Eltima USB to Ethernet wasn't stable enough (timeouts during debug).

SSH tunneling works for free and is more reliable.

@Nathan 2010-04-09 06:14:02

From adb --help:

connect <host>:<port>         - Connect to a device via TCP/IP

That's a command-line option by the way.

You should try connecting the phone to your Wi-Fi, and then get its IP address from your router. It's not going to work on the cell network.

The port is 5554.

@JDM 2010-04-09 21:00:00

I had tried that with 5555-5558 and now 5554 and it it does not work for some reason. Basically from a command line: adb kill-server adb connect 10.10.10.100:5554 with the result being * daemon not running. starting it now * * daemon started successfully * unable to connect to 10.10.10.100:5554 I can ping the ip of the device from the dev workstation. When the output states "daemon started successfully" shouldn't it be referring to the daemon on the device? Is it attempting to use the emulator possibly? How do I ensure/validate the daemon is running on the device? thanks

@Aiden Strydom 2013-03-13 10:27:03

you should first adb tcpip port as the default is debugging over usb. After the latter you can connect connect host:port and it should work

@BrainSlugs83 2013-08-08 17:46:07

"adb tcpip port" literally? that just returns the string "error: device not found" -- is there a typo? Or should I replace something here?

@BrainSlugs83 2013-08-08 17:48:38

AHHH!! Figured it out, the default port number for CyanogenMod is 5555! NICE. :D

@Michael 2013-08-09 16:05:53

Why shouldn't it work over the cell network?

@BrainSlugs83 2013-09-02 22:21:27

@Michael it might work on some cell networks, but their network configurations are basically black boxes -- you don't know when/if you're behind a firewall, if ports are being blocked, if NAT translation is going on, etc.

@andreszs 2015-02-16 18:02:49

OK, this IS the correct answer. You can view the IP from the phone, go to Settings > About Phone > Status. Just set the port with adb tcpip 5555 first when connected via USB. Finally, no more USB cable for deployment, beautiful.

@transistor1 2011-10-14 16:17:45

I needed to get both USB and TCPIP working for ADB (don't ask), so I did the following (using directions others have posted from xda-developers)

Using adb shell:

su
#Set the port number for adbd
setprop service.adb.tcp.port 5555

#Run the adbd daemon *again* instead of doing stop/start, so there
#are two instances of adbd running.
adbd &

#Set the port back to USB, so the next time ADB is started it's
#on USB again.
setprop service.adb.tcp.port -1

exit

@mpontillo 2012-08-02 00:47:44

+1; I like this solution.

@KrisWebDev 2013-08-18 08:30:02

Doesn't work: adbd not found. adbd is normally launched via start adbd. But maybe there's a script/executable in some folder?

@transistor1 2013-08-18 13:12:03

On my gnex, it's /sbin/adbd. That may vary by phone. Of course, you must be rooted... If you're not rooted, you won't be able to access /sbin.

@norman 2010-09-18 01:28:42

This is really simple if your phone is rooted.

Download a terminal emulator from Google Play (there are lots that are free). Make sure that your Android device is connected to your Wi-Fi and get the Wi-Fi IP address. Open the terminal program and type:

su
setprop service.adb.tcp.port 5555
stop adbd
start adbd

Now go to your computer (assuming that you are using Windows) and create a shortcut on the desktop for "cmd.exe" (without the quotations).

Right click on the cmd shortcut and choose "Run as Administrator"

Change to your android-sdk-windows\tools folder

Type:

adb connect ***wifi.ip.address***:5555

(example: adb connect 192.168.0.105:5555)

adb should now say that you are connected.

Note: if you are too fast to give the connect command it may fail. So try at least two times five seconds apart before you say this doesn't work.

@Eduardo 2012-07-14 17:14:30

This answer was better for me because it explained that which part should be performed on the device and which on the computer.

@samis 2013-07-25 15:30:13

BEFORE "adb tcpip 5555" DO "adb kill-server". AFTER "adb connect 192.168.0.101:5555" DO "adb devices" OR "adb shell" (connect doesn't start shell).

@Avinash M 2014-01-31 05:53:25

I just followed following steps and it started working, so that i can connect to my android device.

Step 1: Open the terminal Window in Android Devices and execute the following command.

  1. su -- To switch to super user.
  2. setprop service.adb.tcp.port 5555 - To specify the tcp Port - 5555 is the port number here
  3. stop adbd - To stop the adbb service.
  4. start adbd - To start adbd service.

Step 2: Through ADB, Execute the bellow command.(From the path where ADB is configured)

adb connect 10.10.10.50:5555 - Here 10.10.10.50 is the IP address of the android device and 5555 is the port number.

@offcourse 2011-01-24 05:13:00

As Brian said:

According to a post on xda-developers, you can enable ADB over WiFi from the device with the commands

setprop service.adb.tcp.port 5555

stop adbd

start adbd

And you can disable it and return ADB to listening on USB with

setprop service.adb.tcp.port -1

stop adbd

start adbd

If you have USB access already, it is even easier to switch to using WiFi. From a command line on the computer that has the device connected via USB, issue the commands

adb tcpip 5555

adb connect 192.168.0.101:5555

To tell the ADB daemon return to listening over USB

adb usb

There are also several apps on the Android Market that automate this process.

It works.You just need to access the android shell and type those commands...

One other (easier) solution is on the Market: adbWireless, it will automatically set your phone.

Root is required! for both...

@android.weasel 2012-10-27 17:41:53

...but only if the phone is rooted.

@Aiden Strydom 2013-06-18 16:28:31

Asus Transformer 301 - Working no root required

@Felizk 2013-01-05 13:25:39

I put together a batch file for automatic enabling and connecting ADB via TCP, to a device connected via USB. With it you don't have to put in the IP manually.

@echo off
setlocal

REM Use a default env variable to find adb if possible
if NOT "%AndroidSDK%" == "" set PATH=%PATH%;%AndroidSDK%\platform-tools

REM If off is first parameter then we turn off the tcp connection.
if "%1%" == "off" goto off

REM Set vars
set port=%1
set int=%2
if "%port%" == "" set port=5557
if "%int%" == "" set int=wlan0

REM Enable TCP
adb -d wait-for-device tcpip %port%

REM Get IP Address from device
set shellCmd="ip addr show %int% | grep 'inet [0-9]{1,3}(\.[0-9]{1,3}){3}' -oE | grep '[0-9]{1,3}(\.[0-9]{1,3}){3}' -oE"
for /f %%i in ('adb wait-for-device shell %shellCmd%') do set IP=%%i

REM Connect ADB to device
adb connect %IP%:%port%

goto end

:fail
echo adbWifi [port] [interface]
echo adbWifi off
goto end

:off
adb wait-for-device usb

:end

@lee 2011-06-11 09:31:54

I did get this working. Didn't use any usb cable.

  • app adb wireless.
  • Run it. That will set ip and port; Then in dos

    cd C:\Program Files\Android\android-sdk\platform-tools adb connect "192.168.2.22:8000 "enter"
    

Connected.

@user146043 2012-07-17 08:41:29

I find the other answers confusing. Far simpler to use adbWireless:

http://ppareit.github.com/AdbConnect/

Simply install an app on your phone to toggle debugging over wifi, install an eclipse plug-in and you're done.

@ArtOfWarfare 2012-10-05 15:13:52

What eclipse plug-in are you referring to? Edit: Nevermind. Found it by following the link in your answer.

@Zoe 2017-08-18 10:19:45

This is only root though

@errordeveloper 2012-07-14 16:17:42

To switch between TCP and USB modes with just one command, you can add this to /init.rc:

on property:service.adb.tcp.port=*
    restart adbd

on property:service.adb.tcp.enable=1
    setprop service.adb.tcp.port 5555

on property:service.adb.tcp.enable=0
    setprop service.adb.tcp.port -1

And now you can use property service.adb.tcp.enable to enable or disable listening on port 5555. Run netstat to check whether it's listening. As you can see it will also trigger if you do wish to change service.adb.tcp.port manually.

@user146043 2012-07-16 19:28:53

Additionally...to what?

@errordeveloper 2012-07-16 21:49:07

you're right, I should rephrase it :)

@Joe C 2011-12-22 17:44:18

On my system it went like this:

On my Android device in my Linux shell, a simple "ifconfig" did not give me my IP address. I had to type:

ifconfig eth0

-or-

netcfg

to get my IP address. (I knew eth0 was configured because I saw it in my dmesg.) Then I did the :

setprop service.adb.tcp.port -1

stop adbd

start adbd

Then on my Win7 box (the one running Eclipse 3.7.1). I opened a command prompt to

\android-sdk\platform-tools>

without running as admin. Then I did a

adb connect 12.345.678.90

I never put a port. If I did a

adb tcpip 5555

it said it couldn't find the device then nothing appeared in my "adb devices" list. I.e. it only works if I DON'T do the tcpip command above.

I can do an "adb shell" and mess with my Android Device. But my Android Device does not appear in my Run->Run Configurations->Target tab right now. On the other hand, if I keep the Target Tab set to automatic. Then when I run my app via Run->Run it does run on my Android device even though my Android device is not even listed as one of my targets.

@ConcernedParty 2011-07-22 17:45:23

Use the adbwireless app to enable the phone, then use adb connect from the Windows machine to talk to it. The adbwireless app on the phone tells you how to connect to it, giving the IP address and everything.

The much less fun alternative is to connect via USB, tell the phone to use TCPIP via adb tcpip 5555, then disconnect USB, then use adb connect. This is much harder because this way you have to figure out the IP address of the phone yourself (adbwireless tells you the IP), you have to connect via USB, and you have to run adb tcpip (adbwireless takes care of that too).

So: install adbwireless on your phone. Use it. It is possible, I do it routinely on Linux and on Windows.

Related Questions

Sponsored Content

26 Answered Questions

[SOLVED] Android Studio - Device is connected but 'offline'

  • 2015-06-21 13:08:56
  • Aaron G
  • 84566 View
  • 56 Score
  • 26 Answer
  • Tags:   android-studio adb

25 Answered Questions

[SOLVED] Run/install/debug Android applications over Wi-Fi?

27 Answered Questions

27 Answered Questions

[SOLVED] How can you find out which process is listening on a port on Windows?

77 Answered Questions

11 Answered Questions

[SOLVED] How to start an application using android ADB tools?

  • 2010-12-31 03:33:06
  • Sean
  • 374401 View
  • 403 Score
  • 11 Answer
  • Tags:   android adb

2 Answered Questions

[SOLVED] No Consistent Way to Connect ADB over TCP

9 Answered Questions

1 Answered Questions

Error connecting adb on Android Things

2 Answered Questions

[SOLVED] Unable to connect Android ADB over TCP/IP

  • 2013-04-07 08:13:14
  • Stochastically
  • 16032 View
  • 9 Score
  • 2 Answer
  • Tags:   android tcp adb

Sponsored Content