How can I connect to Android with ADB over TCP?

1,398,263

Solution 1

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.

Solution 2

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. Once you are done, you can disconnect from the adb tcp session by running:

adb disconnect 192.168.0.101:5555

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.

Solution 3

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.

Solution 4

  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.

Solution 5

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

Share:
1,398,263
JDM
Author by

JDM

Updated on July 08, 2022

Comments

  • JDM
    JDM almost 2 years

    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?

    • andreszs
      andreszs over 9 years
      When connected via USB: adb tcpip 5555. Disconnect USB, view phone IP from Settings > About Phone > Status. Now adb connect 192.168.x.x and that's it. No tools, no software. Just Works.
    • Jeff Ward
      Jeff Ward about 9 years
      What Andrew said - these are the official instructions from Google's android developer website, no root necessary. Just worked on my non-rooted HTC One m8 (requires enabling developer options, of course.).
    • Shivam Aggarwal
      Shivam Aggarwal over 8 years
      If adb service runs at port 5037 then why does it locate devices in the range 5555 to 5585 ?
    • DaveTheMinion
      DaveTheMinion about 8 years
      @Andrew Could I use an app such as this to open and close the port without a computer on a Nexus 6 with no root access? I am concerned with the security issues that could arise from leaving port 5555 open when I am on a public network and not using my phone for developing.
    • Michael
      Michael almost 7 years
      @Alex Wait, so you need a USB connection to begin with or it won't work? I was looking for a solution while I wait for a new USB cable...
    • andreszs
      andreszs almost 7 years
      Unless you can find a way to execute adb commands on the phone itself, you will need the cable to run the adb command to change the port. Surely there is some kind of rooted command line app to run adb commands.
    • Khurshid Ansari
      Khurshid Ansari over 6 years
      This blog help me to connect wireless : codetheory.in/…
    • Kamlesh
      Kamlesh about 6 years
      you can check the file at gist.github.com/kamleshkarwande/…
    • Athira Reddy
      Athira Reddy about 5 years
    • Ashok Kumar
      Ashok Kumar almost 5 years
    • Saif Siddiqui
      Saif Siddiqui almost 5 years
      Here is the shell script which I have written which can be used to connect to wifi.github.com/saifsms91/… : Run this script when your device is connected to USB and remove the usb once scripts runs to connect it to wifi
  • JDM
    JDM about 14 years
    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
  • J J
    J J about 13 years
    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
    Kingsolmn about 13 years
    @ J J - Unfortunately, yes. Root required.
  • yingted
    yingted over 12 years
    Also, check your firewall. I had to reconfigure my firewall.
  • Ridcully
    Ridcully over 12 years
    For the second solution (adb tcipip 5555 and adb connect ... there's no root necessary.
  • JDM
    JDM over 12 years
    at the time it was the only solution
  • John
    John almost 12 years
    there are small free apps on the market that launch adb into tcpip mode.
  • Eduardo
    Eduardo almost 12 years
    This answer was better for me because it explained that which part should be performed on the device and which on the computer.
  • ArtOfWarfare
    ArtOfWarfare over 11 years
    What eclipse plug-in are you referring to? Edit: Nevermind. Found it by following the link in your answer.
  • soulseekah
    soulseekah over 11 years
    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
    Rich over 11 years
    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).
  • android.weasel
    android.weasel over 11 years
    ...but only if the phone is rooted.
  • Rohit Sangal
    Rohit Sangal over 11 years
    Thanks for the very good example, can you please tell me the reqiurement of the device to be rooted, is it mandatory.
  • Aiden Strydom
    Aiden Strydom over 11 years
    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
  • Grzegorz D.
    Grzegorz D. about 11 years
    Great! Second solution really doesn't require root!
  • lapo
    lapo about 11 years
    BTW: the first app (the one that "requires fewer permissions") seems to exist no more.
  • Brian
    Brian about 11 years
    @lapo Here is a link to an F-Droid archive of the app f-droid.org/repository/browse/?fdid=siir.es.adbWireless
  • Aiden Strydom
    Aiden Strydom about 11 years
    Asus Transformer 301 - Working no root required
  • samus
    samus almost 11 years
    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).
  • BrainSlugs83
    BrainSlugs83 almost 11 years
    "adb tcpip port" literally? that just returns the string "error: device not found" -- is there a typo? Or should I replace something here?
  • BrainSlugs83
    BrainSlugs83 almost 11 years
    AHHH!! Figured it out, the default port number for CyanogenMod is 5555! NICE. :D
  • KrisWebDev
    KrisWebDev almost 11 years
    You can use restart instead of stop and start
  • KrisWebDev
    KrisWebDev almost 11 years
    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>).
  • KrisWebDev
    KrisWebDev almost 11 years
    Doesn't work: adbd not found. adbd is normally launched via start adbd. But maybe there's a script/executable in some folder?
  • transistor1
    transistor1 almost 11 years
    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.
  • BrainSlugs83
    BrainSlugs83 almost 11 years
    @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.
  • Jay Bobzin
    Jay Bobzin about 10 years
    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
    CoatedMoose about 10 years
    @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.
  • Grim
    Grim almost 10 years
    In console write su first to get a rooted-console.
  • Philipp Rieber
    Philipp Rieber over 9 years
    Worked on my Mac only when leaving out the port number when connecting: "adb connect 192.168.0.101" – no rooting necessary. Great!
  • andreszs
    andreszs over 9 years
    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.
  • andreszs
    andreszs over 9 years
    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.
  • Bron Davies
    Bron Davies about 9 years
    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
    JM Lord about 9 years
    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"
  • Aron Lorincz
    Aron Lorincz almost 9 years
    Debugging is a bit slower if my phone is connected this way. Also, sometimes it falls asleep and that causes an immediate disconnect.
  • Abdul Saleem
    Abdul Saleem almost 9 years
    You're a hero.. By the way, i did it without root.. :-) Thank you
  • mr5
    mr5 almost 9 years
    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
    IronBlossom over 8 years
    Great!! One question can I add multiple devices through tcpip?
  • azizbekian
    azizbekian over 8 years
    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?
  • rostamiani
    rostamiani over 8 years
    This error occures: "'adb'command not found. Review your Android SDK installation.
  • Pedro Vicente Gómez Sánchez
    Pedro Vicente Gómez Sánchez over 8 years
    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
    powder366 over 8 years
    Im using mac, don't see an icon in AS? Do I need to do something manual first?
  • Pedro Vicente Gómez Sánchez
    Pedro Vicente Gómez Sánchez over 8 years
    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
    powder366 over 8 years
    @PedroVicenteGómezSánchez Thanks. I picked the wrong plugin, there exist another plugin with similar name...
  • Shivam Aggarwal
    Shivam Aggarwal over 8 years
    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
    Script Kitty over 8 years
    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
    aleksamarkoni over 8 years
    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.
  • Ian Ni-Lewis
    Ian Ni-Lewis over 8 years
    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.)
  • ahsan.dev
    ahsan.dev about 8 years
    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
    iSrinivasan27 about 8 years
    @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
    Eddy about 8 years
    @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!
  • Chris623
    Chris623 almost 8 years
    this plugin is really great and easy to use :)
  • UserInteractive
    UserInteractive almost 8 years
    This worked. However. After performing these steps, I can no longer switch back to the emulator. Suggestions?
  • Thiago
    Thiago almost 8 years
    You need to restart your adb with: <adb kill-server> and then <adb start-server>
  • Josh
    Josh almost 8 years
    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!
  • RaRa
    RaRa about 7 years
    moto g play connect successfully, but when remove usb, both the connection terminate, FYI- i am already connected with other device.
  • Michael
    Michael almost 7 years
    adb shell ip -f inet addr show wlan0 Is the IP address and port support to be substituted in somewhere therE?
  • Zoe stands with Ukraine
    Zoe stands with Ukraine almost 7 years
    not in that line. That is the shell-way to get the IP. Nothing in there should be replaced in that line
  • Zoe stands with Ukraine
    Zoe stands with Ukraine almost 7 years
    This is only root though
  • vhamon
    vhamon almost 6 years
    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
  • Diaa Saada
    Diaa Saada almost 6 years
    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 ?
  • RogerW
    RogerW almost 6 years
    Of all the complicated answers that received massive upvotes, this 8 year old answer his the simplest and works No rooting required. Just type 'adb connect <ip>:5555' and it will be available to be deployed to.
  • tngotran
    tngotran about 5 years
    correct from above question: adb tcip 5555 and adb connect your_android_ip_address you can find your android's ip in settings->about system
  • Angelina
    Angelina about 5 years
    I tried adb tcpip 5555 and then the other person executed adb connect myIP:5555 on their PC. He could install an app to my phone but he could not debug it remotely. Is it possible to debug remotely? On my phone there was a dialog waiting for debugger forever.
  • Zaffy
    Zaffy almost 5 years
    If you don't know the device's IP after you execute adb tcpip, here's a useful shortcut: adb shell ip --brief addr
  • e-info128
    e-info128 almost 5 years
    Without root: disable and enable again the usb debug.
  • Hritik
    Hritik almost 5 years
    Does this make the settings persistent across reboots ?
  • Manju
    Manju over 4 years
    Thanks for sequence of steps and mentioning exactly when to disconnect PC.
  • CaptainFreedom
    CaptainFreedom over 4 years
    Does this work with ipv6 address via mobile internet?
  • Anil GR
    Anil GR over 4 years
    How do I connect to an emulator on another computer over network ?
  • Spikatrix
    Spikatrix over 4 years
    Is it possible to prevent the phone from resetting the adb tcpip 5555? When I don't connect wirelessly to the phone via adb connect for a few days using the method you said, I'm unable to connect until I repeat the steps again, i.e, adb tcpip 5555