How can I connect to Android with ADB over TCP?
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
-
Connect device via USB and make sure debugging is working, then run:
adb tcpip 5555 adb connect <DEVICE_IP_ADDRESS>:5555
Disconnect USB and proceed with wireless debugging.
-
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
Activate debug mode in Android
Connect to PC via USB
Open command prompt type:
adb tcpip 5555
Disconnect your tablet or smartphone from pc
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
JDM
Updated on July 08, 2022Comments
-
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 over 9 yearsWhen connected via USB:
adb tcpip 5555
. Disconnect USB, view phone IP fromSettings > About Phone > Status
. Nowadb connect 192.168.x.x
and that's it. No tools, no software. Just Works. -
Jeff Ward about 9 yearsWhat 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 over 8 yearsIf adb service runs at port 5037 then why does it locate devices in the range 5555 to 5585 ?
-
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 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 almost 7 yearsUnless 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 over 6 yearsThis blog help me to connect wireless : codetheory.in/…
-
Kamlesh about 6 yearsyou can check the file at gist.github.com/kamleshkarwande/…
-
Athira Reddy about 5 years
-
Ashok Kumar almost 5 years
-
Saif Siddiqui almost 5 yearsHere 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 about 14 yearsI 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 about 13 yearsDo 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 about 13 years@ J J - Unfortunately, yes. Root required.
-
yingted over 12 yearsAlso, check your firewall. I had to reconfigure my firewall.
-
Ridcully over 12 yearsFor the second solution (
adb tcipip 5555
andadb connect ...
there's no root necessary. -
JDM over 12 yearsat the time it was the only solution
-
John almost 12 yearsthere are small free apps on the market that launch adb into tcpip mode.
-
Eduardo almost 12 yearsThis answer was better for me because it explained that which part should be performed on the device and which on the computer.
-
ArtOfWarfare over 11 yearsWhat eclipse plug-in are you referring to? Edit: Nevermind. Found it by following the link in your answer.
-
soulseekah over 11 years
adb tcpip <port>
still requires eitherro.kernel.qemu
property to be set (running in emulator mode),ro.secure
to be 0 (i.e. a rooted device), orro.debuggable
andservice.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.cadb_main
parts about thesecure
variable.adbd
on my unrooted 2.3.7 Android does not enter TCP/IP mode at all. -
Rich over 11 yearsOne 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 over 11 years...but only if the phone is rooted.
-
Rohit Sangal over 11 yearsThanks for the very good example, can you please tell me the reqiurement of the device to be rooted, is it mandatory.
-
Aiden Strydom over 11 yearsyou should first
adb tcpip port
as the default is debugging over usb. After the latter you can connectconnect host:port
and it should work -
Grzegorz D. about 11 yearsGreat! Second solution really doesn't require root!
-
lapo about 11 yearsBTW: the first app (the one that "requires fewer permissions") seems to exist no more.
-
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 about 11 yearsAsus Transformer 301 - Working no root required
-
samus almost 11 yearsBEFORE "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 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 almost 11 yearsAHHH!! Figured it out, the default port number for CyanogenMod is 5555! NICE. :D
-
KrisWebDev almost 11 yearsYou can use
restart
instead ofstop
andstart
-
KrisWebDev almost 11 yearsNote 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 almost 11 yearsDoesn't work: adbd not found. adbd is normally launched via start adbd. But maybe there's a script/executable in some folder?
-
transistor1 almost 11 yearsOn 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 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 about 10 yearsHere'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 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 almost 10 yearsIn console write
su
first to get a rooted-console. -
Philipp Rieber over 9 yearsWorked on my Mac only when leaving out the port number when connecting: "adb connect 192.168.0.101" – no rooting necessary. Great!
-
andreszs over 9 yearsOK, 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 over 9 yearsActually, 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 about 9 yearsAll 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 about 9 yearsI 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 almost 9 yearsDebugging is a bit slower if my phone is connected this way. Also, sometimes it falls asleep and that causes an immediate disconnect.
-
Abdul Saleem almost 9 yearsYou're a hero.. By the way, i did it without root.. :-) Thank you
-
mr5 almost 9 yearsFor 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 theadb tcpip 5555
command hangs, it just doesn't work. Good answer btw. -
IronBlossom over 8 yearsGreat!! One question can I add multiple devices through tcpip?
-
azizbekian over 8 yearsGetting 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 over 8 yearsThis error occures: "'adb'command not found. Review your Android SDK installation.
-
Pedro Vicente Gómez Sánchez over 8 yearsYou 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 over 8 yearsIm using mac, don't see an icon in AS? Do I need to do something manual first?
-
Pedro Vicente Gómez Sánchez over 8 yearsI'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 over 8 years@PedroVicenteGómezSánchez Thanks. I picked the wrong plugin, there exist another plugin with similar name...
-
Shivam Aggarwal over 8 yearsIf 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 over 8 yearsThanks 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 over 8 yearsI 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 over 8 yearsThis 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 about 8 yearsAdditionally, 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 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 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 almost 8 yearsthis plugin is really great and easy to use :)
-
UserInteractive almost 8 yearsThis worked. However. After performing these steps, I can no longer switch back to the emulator. Suggestions?
-
Thiago almost 8 yearsYou need to restart your adb with: <adb kill-server> and then <adb start-server>
-
Josh almost 8 yearsThis 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 about 7 yearsmoto g play connect successfully, but when remove usb, both the connection terminate, FYI- i am already connected with other device.
-
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 almost 7 yearsnot 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 almost 7 yearsThis is only root though
-
vhamon almost 6 yearsOn 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 almost 6 yearscan 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 almost 6 yearsOf 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 about 5 yearscorrect 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 about 5 yearsI tried
adb tcpip 5555
and then the other person executedadb 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 dialogwaiting for debugger
forever. -
Zaffy almost 5 yearsIf 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 almost 5 yearsWithout root: disable and enable again the usb debug.
-
Hritik almost 5 yearsDoes this make the settings persistent across reboots ?
-
Manju over 4 yearsThanks for sequence of steps and mentioning exactly when to disconnect PC.
-
CaptainFreedom over 4 yearsDoes this work with ipv6 address via mobile internet?
-
Anil GR over 4 yearsHow do I connect to an emulator on another computer over network ?
-
Spikatrix over 4 yearsIs it possible to prevent the phone from resetting the
adb tcpip 5555
? When I don't connect wirelessly to the phone viaadb 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