Related
When I try to connect my mobile device using adb connect 192.168.1.4:5037 i get failed to connect to '192.168.1.4:5037': Connection refused error sometimes.
How can I fix this? This issue happens intermittently. What is the reason behind this & how to fix it?
I even tried killing and restarting adb server
My steps
adb tcpip 5555
adb connect 192.168.1.4:5555
Additional Info
Device - Poco F1
Android - 10
You need to run adb tcpip 5555 with the USB cable plugged in - and then unplug.
Try following these instructions:
Open the command prompt and navigate to your sdk/platform-tools/ folder.
Type adb tcpip 5555 with your device plugged in
Type adb connect <your device ip address>:5555
At this point you unplug your device and type adb logcat
At times, such as unplugging/plugging into a USB device, the logcat will become disconnected, just redo steps 3 & 4.
ping 192.168.1.4 to see if this IP is online.
telnet 192.168.1.4 5555 to see if this port is online.
Phone should be connected over USB cable before making connection over Wi-Fi. Once you successfully connected to the device you can unplug the cable.
Just in case, try
adb kill-server
to restart the server
And make sure developer settings and USB debugging enabled, so it must be working via USB cable
Option I: This might happen when your device keeps changing IP addresses, since WiFi is sometimes switched on and off, and when you get a DHCP lease from your server/Access Point it might change. Keeping your device plugged in via USB (not necessarily to the host, but to any charger), or keeping screen on will ensure it's at the same address, and - assuming that you have the address right and you used adb tcpip (or set the adb TCP property in the shell) it should work.
Option II: You have the port number wrong. "Connection refused" means you got to the IP address, but the port isn't listening. Up there in your question you first state 5037, then 5555?
I am trying to connect to an Android device with Marshmallow for wireless debugging.
C:\...\sdk\platform-tools>adb connect 192.168.1.103:5555
unable to connect to 192.168.1.103:5555: cannot connect to 192.168.1.103:5555:
No connection could be made because the target machine actively refused it. (10061)
I also tried adb connect "192.168.1.103:5556" and "adb connect 192.168.1.103" but ended up with same result.
The first command above used to work fine on my OnePlus Two before the Marshmallow update.
Any help on how to do wireless debugging on Marshmallow?
I am also using the One Plus two and updated to marshmallow 2 weeks ago . i have the same issue
try to kill your adb sever then try again .
adb kill-server
you should use 5556 port number not 5555 anymore
if its not working connect your phone via usb cable then restart the adb into wireless mode
adb tcpip 5556
then try to connect your phone with the port no 5556 (eg ip:5556) after connected you can remove your usb cable
it worked for me
Connect the Android device with the computer using your USB cable.
Restart adb in tcpip mode
adb tcpip 5556
Now try to reconnect the android device.
at first ping your Android Device IP from pc and ping your PC IP from Android Terminal Emulator make shore got replay (it means wireless connecting is stable and no firewall problem)
connect USB chek "adb devices" in command line
in this level you must have device name (esle must use other command likd eadb kill-server & adb start-server or chek device driver)
make your Device conncet first and work truly (many reason like your device driver and other thing must cheked in this case)
after that try "adb connect 192.168.1.3:5555" (your device IP And always POST is 5555 and some time 5556)
if got error like (10061) test this "adb tcpip 5555"
after that tray again "adb connect 192.168.1.3:5555"
if this doset work unplug usb connection and connect again and tray one more time
after connecting to device you device ip display in devices list in ADT now you must unplug USB if lost connection , dont wory just try "adb connect 192.168.1.3:5555" one more time but whitout USB cable (it just for first time wireless connecting need usb)
It seems that wireless ADB has more and more issues each time I update Android Studio. Using 2.1.1, I'm now unable to connect to my tablet using the command:
adb connect <ip addr>
It results in the error:
unable to connect to <ip addr>:5555: cannot connect to <ip addr>:5555: No connection could be made because the target machine actively refused it. (10061)
This happens directly after approving the connection in the dialog box on the tablet. Before today I was forced to do an adb kill-server prior to attempting to connect to the tablet but now that doesn't even help.
Generally you can say this error is network related, check these items first:
make sure your computer and your device can see each other in network mostly this means they are connected to the same router, but in more advanced scenarios your device may be connected to a wireless router and you computer may be connected to you Local Area Network. what is important is they can see each other. you can check this by pinging you device ip address from you computer.
make sure there is no conflict with ip addresses, this might be very simple. but if you do not use DHCP server and you enter the ip addresses in you devices you could mistakenly entered same ip address in different devices
when you are sure about the network issues redo the famous steps
So when you connected by USB follow these commands:
stay connect via USB
connect to your WIFI network (computer and mobile device both)
ping DeviceIP (must be have ping to your device)
adb kill-server
adb usb
adb tcpip 5555
unplug usb cable (as per #captain_majid 's comment)
adb connect yourDeviceIP
adb devices (must be see two device names , one of them is by deviceIP)
unplug USB cable
Steps from could not connect to tcp:5037: cannot connect to 127.0.0.1:5037: No connection could be made because the target machine actively refused it. (10061)
when restart device then your port also channge so hit command below
1- adb kill-server
2- connect your phone to pc with usb cable
3- adb tcpip 5555
4- adb connect (your device ip):5555
Device and PC are connected to same network connection.
1 stay connect via USB
2 adb kill-server
3 adb usb
4 adb tcpip 5555
5 adb connect 192.168.43.1:5555
6 adb devices (must be see two device names , one of them is by deviceIP)
7 unplug USB cable
I had the same issue. These steps worked for me:
connect your device with usb
when your cmd already in AppData\Local\Android\Sdk\platform-tools>,type adb tcpip 5555
the cmd will show restarting in TCP mode port: 5555
type adb connect 192.168.43.1:5555
Hope this can solve your issue.
I recently faced the same problem.
It occurs because your device and PC are connected to different Networks.
when restart device then your port also channge so hit command below
1- adb kill-server
2- adb tcpip 5555
3- adb connect (your device ip):5555
I got this error when I had Bluestacks emulator started together with my phone attached.
When I typed in command prompt adb devices I could see two devices:
adb devices
List of devices attached
dfdcdc9c device
emulator-5554 device
Before typing adb connect I had to type -s and device ID:
adb -s dfdcdc9c tcpip 5555
adb -s dfdcdc9c connect <ip addr>
In case of me, i tried different port 5557 than again 5555,
adb tcpip 5557
adb connect device_ip_address
gives same error(10061) than again tried with,
adb tcpip 5555
adb connect device_ip_address
result: connected
that works for me(while the other thing is ok like as developer option is on and connected to same wifi)
Make sure you have to connect your phone through a USB cable for the first time.
Using Command prompt, Go to your Android SDK Directory (sdk->Platform-tools) and then
run the following commands
1- adb kill-server
2- adb tcpip 5555
3- adb connect 192.168.1.130 (Replace IP Address with your phone IP)
4- Now you can unplug it.
5- Then go to the Android studio and choose the device with IP address in
Run
Dropdown. Hope this will help it for everyone.
And then for next times just runs following command
adb connect 192.168.1.130:5555
Note: If Device is not showing in Android studio devices dropdown then
connect **USB** and run following commands
1-adb kill-server
2-adb usb
3-adb tcpip 5555
4-adb connect 192.168.1.130:5555
You must connect the mobile device via USB first, then type adb tcpip 5555 ,
and then enter your device IP adb connect <your_device_ip>
I solved the problem by enabling USB Debugging in Developer Options.
Unfortunately this issue can be caused by different reasons.
One of the reasons - make sure previous communication is disconnected.
USE:
1. adb kill-server
2. Issue command adb disconnect after restarting adb server. Do same thing after finishing job
3. run adb remount
4. adb tcpip 50555 (I usually use higher port number)
5. unplug USB cable
6. adb connect device_ip:50555
when done run adb disconnect
Following steps are standard ones to follow( mostly same as previous answers):-
adb tcpip 5555.
adb connect your_device_ip_address.
adb devices (to
see if devices got connected).
But in some cases above steps gives error like "unable to connect to device. Make sure that your computer and your device are connected to the same WiFi network." And you notice the devices are already on the same network.
In this case, install this plugin "Wifi ADB Ultimate" and follow below steps.
Connect the device once through USB.
Refresh the list to check whether its connected.
Go to About Phone > Status > IP Address and note your IP
address(e.g. 198.162.0.105).
Come back to Android Studio and fill in this IP as done in below
photo and hit the run button.
I had same issue with Android Studio 3.5.2, here is how i solved it.
First you must connect your device via USB once. (Debugging mode starts only when usb is connected)
Go to command prompt :
adb tcpip 5555
(watch for port on which adb started)
then : adb connect :
After successful connection goto Studio>Run>Select Device.
I assume you already solved the problem by now. but here is the way to avoid the problem if you are using multiple devices. I used to have the same issue so many times until I understand, how it works.
I was also trying to connect multiple devices one after another or trying to connect the same device after a while.
Always make sure to disconnect the older device before you connect the new device:
adb disconnect
after that, you will be easily able to connect new device:
adb tcpip 5555
adb connect <your_device_ip>
you can always try to ping the device using the ping command, if the ping is not getting acknowledgment then you must have connected to different wifi then your laptop or you haven't connected to wifi at all:
ping <your_device_ip>
For anyone who is Android 11+
Enable Developer Options
Enable Wireless Debugging
Allow wireless debugging on this network.
Pair Device with Pairing code
Type in adb pair [Phone_IPAddress]:[PORT] [PAIRING CODE]
After Successfully Pairing. Type adb connect [Phone_IPAddress]:[PORT]
For more info: ADB Documentation
Usually the 'target machine actively refused it' message is displayed when the target machine's 'ADB debugging' feature is not turned ON. It is turned off by default in almost all devices unless we enable 'developer options'. So whenever you land on this error, make sure you go to the settings of your target machine and trickle to the developer/development area and somewhere there should be a place to enable ADB.
After weeks of struggle and trying different approaches while everything was right and on the same network (ping {ip} was coming back positive) I figured the dumb debug bridge does not look for all network adapters to find the device! The device got connected when I manually disabled all other network adapters except the one (WiFi adapter) which was required to connect.
Step 1. Type command in terminal adb tcpip 5555
Step 2. Type command in terminal adb connect <your_phone_ip>:5555
Now check in studio device Monitor tool your phone connected without wire.
Note :- Most important your Laptop & Mobile Device Connected with same Network
I had the same issue and I thought it might be because of the network and tried many solutions but didn't work. Lastly, I checked my IP address which was updated for my device and was the root cause for this.
So please check the IP address first and use adb tcpip <port> to start listening the connection and adb connect <IP>:<PORT>
Try this way change adb to .\adb
PS C:\users\mori\appdata\local\android\sdk\platform-tools> .\adb kill-server
PS C:\users\mori\appdata\local\android\sdk\platform-tools> .\adb usb
PS C:\users\mori\appdata\local\android\sdk\platform-tools> .\adb tcpip 5555
PS C:\users\mori\appdata\local\android\sdk\platform-tools> .\adb connect 192.168.1.34:5555
connected to 192.168.1.34:5555
I had a similar problem. I found out the problem was if I had other devices/emulators connected to the adb already, the "adb connect <ip_addr>" command would give me the "No connection could be made because the target machine actively refused it" message.
The solution is to make sure all the other devices/emulators are disconnected (either physically disconnect or quit the emulator application) before running adb connect <ip_addr>. You can then reconnect your other devices (if you need them reconnected). A total pain.
Your mileage to this solution may vary depending on your problem.
I got this error when trying to establish an ADB connection to a smartwatch with WearOS 1.0 (Huawei Watch 2) via WiFi. Enabling the menu entry for fixing some WLAN issue ("Fix error via WLAN" -- my own rough translation of the German caption "Fehler über WLAN beheben") in the "Developer options" on the WearOS device solved the issue for me.
I had the same issue. It was working perfectly for a month, and then one day it stopped working. I tried all the solutions above, but to no avail. Then, I noticed that for some reason, the IP address of my phone had changed, ending with the number 1 instead of 0. So I connected to the new address with 1 as the last digit in the address and now it works again. Weird.
In my case I played with my device long enough to somehow mess up adb deamon, so port number was not set up correctly anymore.
getprop service.adb.tcp.port returned empty string.
So I solved this with following commands:
stop adbd
setprop service.adb.tcp.port 5555
start adbd
I ran all commands on rooted device in app that emulates command prompt.
So I came here because I want to adb shell into my physical Android phone over the network. Lots of useful answers are provided, but the most obvious fact is never stated. Here is the #0 fact:
The Android phone should ALWAYS be connected via USB to the laptop
And then another different laptop will do adb connect ...
This was not what I had in mind and all the above answers never mentioned it.
Go to Android Studio File - Settings
Next..
Happy Codding :)
I had a problem with my Huawei. For some reason I had wrong drivers, on Device Manager it was showed like "Android Phone". Then, I updated the drivers from Device Manager, I choose another driver and now it is showed as "Huawei" device.
From there I connected my device whitout problem (adb connect IP:5555)
For Android TV, Connect PC and TV in the same network (wi-fi),
enable developer option, and go to developer option and enable ADB debugging option.Then run the commands given below
1. ping <ur IP> (check the connection)
2. adb disconnect (to remove all the previous connections)
3. adb connect <Ur IP>
4. adb install app_name.apk
I have attempted to use many solutions above to no avail and found some pretty simple solution that works for myself.
If you are using a real device to debug like me, you may check the device official website to download the android USB driver for your development environment.
I'm using Samsung phone to debug and using windows as development environment thus I went here, download the Android USB Drivers for Windows and run it.
It resolves my ADB problem.
For some reasons, my phone does not work anymore with cable.
I saw on the Internet that it is possible to connect adb to the via Wifi, however I tried it and I get this:
adb devices
List of devices attached
192.168.1.2:5555 offline
I search this on Google and it seems that it is related to Android 4.2.2.
And indeed, my device is running Android 4.2.2.
I didn't find any answers on Google for my problem since it is always with a cable, mine is on Wifi...
Any idea how to solve this?
For me the complete steps that worked were :
Settings -> Developer options -> Revoke USB debugging authorizations (clear the list of authorized PCs).
Set USB Debugging OFF.
In Terminal write : adb kill-server
Then : adb start-server
Then : adb connect xx.xx.xx.xx:5555 (the devices ip), it should say unable to connect.
Now turn ON USB debugging again and type the adb connect xx.xx.xx.xx:5555 again.
It should now ask for authorization and you are back online without
needing to connect cable to USB, only wifi used.
run adb kill-server, then try to connect wirelessly again. It worked for me.
I could not find exact solution for this problem too.
Best way worked for me was disconnecting device from wifi, then try to connect while device is not connected to Wifi like:
adb connect 192.168.55.3:5555
this causes adb waiting for connection. immediately connect device to wifi and adb will detect device and connect again.
hope this helps.
Disconnect adb over wifi, connect your phone with a USB-cable to your pc. It will ask you on your phone is you want to allow the connection. Tick always allow. You will only get this when you connect with USB and have to do this only once, you can use over wifi afterwards.
Don't get the pop-up? Try the answers on google over a cable, since you need to do this first.
It seems you want authenticate adb over wifi.If you had your device rooted,you can try this way.
Copy ~/.android/adb_key.pub to your android device,and rename it to adb_keys
Move it to your /data/misc/adb/
Reboot your android,then reconnect over wifi.
For the first time in debug mode, you need to Authorize your phone with the PC, and that requires the USB cable. After that you can use Debug over WIFI.
If you want to force your phone to show the Authorization message box, simply delete the below file.
/data/misc/adb/adb_key
In android studio go to Preferences->Plugins
Download and install this plugin
ADB WIFI Connect
, restart Android Studio
Connect phone via USB
In android terminal use command: adb devicesyou should get visible device connected via USB:
List of devices attached
988a57334e57365058 device
Click on plugin icon in android studio AndroidWiFiADB
If phone get connected properly via WiFI, you see in event log:
12:41 Android WiFi ADB: Device 'ModelOfYourPhone' connected.
In android terminal use command: adb devices use should get
List of devices attached
988a57334e57365058 device
192.168.60.101:5555 device
Disconnect USB cable and re-check again adb devices, should remain only device connected via wifi:
List of devices attached
192.168.60.101:5555 device
Try disconnecting your device with:
abd disconnect <IP/TCP>:<port>
Then restart the WiFi connection of your device, and reconnect your device with:
abd connect <IP/TCP>:<port>
That may fix it; it worked for me.
For me, the important part turned out to be the following line adb tcpip 5555 together with using the port in the IP of my phone like so: adb connect 192.168.1.87:5555 (only using one of them, did not work, i.e: writing the second alone didn't work, writing the first and then excluding the port in the IP also didn't work). The adb tcpip 5555 line is not mentioned anywhere here. So, for me, the PORT needed to be both manually set and used in the connect line!
These are the events of my command line in Windows PowerShell Admin to demonstrate (Wifi on and debug mode on and confirmed permission when the popup came):
notice that the connection first failed, then it said it was connected which is weird behavior to begin with (no matter what, it always failed once and "succeeded" once), and in both instances, the device showed as offline. The disconnect commands also confirm that its 110% offline
PS C:\WINDOWS\system32> adb kill-server
PS C:\WINDOWS\system32> adb start-server
error: protocol fault (couldn't read status): Connection reset by peer
PS C:\WINDOWS\system32> adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
PS C:\WINDOWS\system32> adb connect 192.168.1.87:5555
failed to connect to 192.168.1.87:5555
PS C:\WINDOWS\system32> adb devices
List of devices attached
220947272e047ece device
192.168.1.87:5555 offline
PS C:\WINDOWS\system32> adb connect 192.168.1.87:5555
already connected to 192.168.1.87:5555
PS C:\WINDOWS\system32> adb devices
List of devices attached
220947272e047ece device
192.168.1.87:5555 offline
PS C:\WINDOWS\system32> adb disconnect 192.168.1.87:5555
error: no such device '192.168.1.87:5555'
PS C:\WINDOWS\system32> adb disconnect 192.168.1.87:5555
error: no such device '192.168.1.87:5555'
PS C:\WINDOWS\system32> adb tcpip 5555
restarting in TCP mode port: 5555
PS C:\WINDOWS\system32> adb disconnect 192.168.1.87:5555
error: no such device '192.168.1.87:5555'
PS C:\WINDOWS\system32> adb connect 192.168.1.87:5555
connected to 192.168.1.87:5555
PS C:\WINDOWS\system32> adb devices
List of devices attached
220947272e047ece device
192.168.1.87:5555 device
As soon as I added the adb tcpip 5555 command and it restarted in TCP mode port: 5555 the adb connect 192.168.1.87:5555 command worked!
Make sure that pc is authorized in the device by going to Developer options -> Revoke USB debugging authorisations and then trying to connect via USB. After accepting the PC, disconnect the cable and connect through wifi.
adb kill-server
adb run-server
adb connect IP:5555
Although in my case, when I tried to connect it failed at first and second try it said already connected.
I disconnected from the device and connected again and it solved.
adb disconnect ip:5555
adb connect ip:5555
I solve this problem for huawei P10.
its about phone's developer settings => find usb developer settings, and under usb developer setting there is a "adb debugging in charging mode..." enable it. My problem solved with this way. Hope yours too....
My solution steps:
Turn Off WiFi and Turn it back On again.
Settings -> Developer options -> Revoke USB debugging authorizations.
Settings -> Developer options -> Turn Off ADB over network and turn it back On again.
adb kill-server
adb start-server
adb connect xx.xx.xx.xx:5555
Note: Step 3 was the key for me. don't forget it.
In simple cases it will start after Enabling USB debugging
For complexities you need to delete the
adbkey
file from
C/.android and then running following commands in command prompt
adb kill-server
adb start-server
adb devices
Note that wireless adb connectivity in Android 6.0.0 is broken. Updating to 6.0.1 fixes the issue.
https://stackoverflow.com/a/34530543/1123355
In Windows, if you are using system-wide proxy software like Proxifier, you need to add adb.exe to the ingore list or direct-mode list. In my case, using Proxifier will make adb able to connect to any IP address even when the phone is not connected to the WiFi, and this leads to device offline.
I know its late to answer but I believe this is the exact answer:
go to WIFI setting on your device and "set a new IP" in your network IP range an reconnect.
Conflicting ADB connections can cause this issue as well:
Windows Host with Docker to Hyper-V Android x86 emulator
I didn't see this answer here yet so for those attempting something similar, the issue I had was that the local Windows Host ADB process had already acquired the adb connection during start up (adb server start).
By simply running: adb disconnect <Device/Android x86 Hyper-V ip>:5555
on host machine
Running adb connect <Device/Android x86 Hyper-V ip>:5555 on the Docker container was able to successfully acquire the remote device (aka Android x86 Hyper-V)
IMPORTANT!!! Until you disconnect Docker (or whatever), your host machine (or any others) will not be able to connect, apparently only one ADB connection at a time is allowed.
I didn't need to do anything else listed above. Hope this helps others.
Just turn off your Proxifier or something else like this.
Socks5 works fine
Watever! I'm always using these steps to connect ADB Wifi with android studio
STEP-1:
1. Go to Android studio->Settings-> Plugins -> Search ADB WIFI
2. Install the pluging and restart android studio
STEP-2:
1. Find the location of SDK Manager For ex for my computer
Copy the whole location
Now open Terminal in Android studio itself( This will show in right bottom corner).
type cd YOUR_SDK_LOCATION
type cd platform-tools
Now type adb tcpip 5555
FOR NEXT STEP YOU MUST CONNECT YOUR MOBILE AND LAPTOP WITH SAME WIFI
type adb connect 192.168.6.100:5555 in terminal (Here 192.168.6.100 is your mobile IP Address)
now the message will show like this 'connected to 192.
168.6.100:5555'
STEP -3 :
1.Go to Android studio->Tools->ADB WIFI-> ADB Restart
1.Go to Android studio->Tools->ADB WIFI-> ADB USB to WIFI
Like below
That's it .
In My case my wifi network is not same thats why i am not getting connected with the device.
There is very easy and helpful plugin for this purpose Android Wifi ADB
How to Connect using plugin:
connect device using cable
click on Android wifi adb icon
disconnect your USB connection now your device is connected over wifi.
Enjoy Happy debugging.
adb reconnect offline
adb connect [ip]:[port] (for exemple adb connect 192.168.8.100:44
While all tips with killing ADB server helped me many times, now I got the message:
cannot connect to <IP>:<port>: No connection could be made because the target machine actively refused it. (10061)
It was possible to attach the device only while it was connected with USB, and after disconnecting cable it appeared as offline at the attached devices list.
I have just solved my problem by changing the USB configuration:
Developer options > Select USB Configuration: MTP (Media Transfer Protocol)
PTP (Picture Transfer Protocol) works as well.
Screenshot
I hope it will help.
I have this problem just now. Note that my case is special, the usb has been disabled for security concerns. Reboot not working. This is not ip problem since ping is working and nmap shows 5555 port is open. Also since I will not able to connect if port is wrong, so nothing to do with port.
There are 4 reasons:
Because another pc in the local network already connected, so the other guy have to adb disconnect first, then I can do adb disconnect and adb connect <ip>, since only one person can connect at the same time.
A hotspot ssid name might consists of multiple bssids in (especially you're in office) local network, so you need to ensure your pc try all the hotspot bssids which match the android connected hotspot bssid. Note that I noticed it's not always the case (Now I tried different bssids still success), but it did solved before.
Ensure the port 5555 is open correctly. Even though there are many ways, but you can download this app to open port 5555.
And I just encounter a weird case, client A connect just fine. But then client B turn on wifi and attempt to connect but failed. Then this failure causes original client A no longer able to connect. Reboot device/adb disconnect/adb kill-server doesn't help, and confirmed the ip is same(tested by turn off/on device and observe the ping). I make a joke about client B wifi still turn on may interfere the device wifi. Then I realized Client B disconnect/kill-server is not enough, client B also need turn off wifi to make client A connect. And it did.
Try,
adb disconnect <your_ip_address>:port_number or adb disconnect
eg.
adb disconnect 192.168.1.2:5555
Or
adb disconnect
The difference is that first one will disconnect only the required device, the second one will disconnect all the devices.
The benefit of using this command is that you don't have to kill and restart the server. Killing and restarting the server requires your device to be plugged in to your computer which is most irritating process.
For me the reason is GLOBAL PROXY (A country without international internet). Adb try to connect my device through proxy server.
I thought there was a way to test your applications in development over Wi-Fi. Is this possible?
I'd love to be able to untether my phone and develop wirelessly.
See forum post Any way to view Android screen remotely without root? - Post #9.
Connect the device via USB and make sure debugging is working;
adb tcpip 5555. This makes the device to start listening for connections on port 5555;
Look up the device IP address with adb shell netcfg or adb shell ifconfig with 6.0 and higher;
You can disconnect the USB now;
adb connect <DEVICE_IP_ADDRESS>:5555. This connects to the server we set up on the device on step 2;
Now you have a device over the network with which you can debug as usual.
To switch the server back to the USB mode, run adb usb, which will put the server on your phone back to the USB mode. If you have more than one device, you can specify the device with the -s option: adb -s <DEVICE_IP_ADDRESS>:5555 usb.
No root required!
To find the IP address of the device: run adb shell and then netcfg. You'll see it there.
To find the IP address while using OSX run the command adb shell ip route.
WARNING: leaving the option enabled is dangerous, anyone in your network can connect to your device in debug, even if you are in data network. Do it only when connected to a trusted Wi-Fi and remember to disconnect it when done!
#Sergei suggested that line 2 should be modified, commenting: "-d option needed to connect to the USB device when the other connection persists (for example, emulator connected or other Wi-Fi device)".
This information may prove valuable to future readers, but I rolled-back to the original version that had received 178 upvotes.
On some device you can do the same thing even if you do not have an USB cable:
Enable ADB over network in developer setting
It should show the IP address
adb connect <DEVICE_IP_ADDRESS>:5555
Disable the setting when done
Using Android Studio there is a plugin allowing you to connect USB Debugging without the need of using any ADB command from a terminal.
(No root required) There is one best, easy and with UI method for Android Studio
IntelliJ and Android Studio plugin created to quickly connect your Android device over WiFi to install, run and debug your applications without a USB connected. Press one button and forget about your USB cable.
just install plugin Android WiFi ADB
Download and install Android WiFi ADB directly from
Intellij / Android Studio: Preferences/Settings->Plugins->Browse Repositories
.
Remember! for first time to initialize the device you must have to connect using usb
Alternatively, you can download the plugin from the JetBrains plugin site and install it manually in: Preferences/Settings->Plugins->Install plugin from disk.
You can connect and manage your devices easily....... for more information read here https://github.com/pedrovgs/AndroidWiFiADB
If you want to enable wireless adb on the device without connecting with a USB cable at all (root required):
Install a terminal app on the device (like Android Terminal Emulator)
Type the following
su
setprop service.adb.tcp.port 5555
stop adbd
start adbd
Since you already have the terminal opened, you can find the IP address of the device:
ip addr show
Then in your debugging environment run command:
adb connect ip.of.the.device
This will make the device to be listed as any other emulators you might have. Note that the TCP will stay opened until you reset the device.
You might also want to install a Wi-Fi Keep Alive app if you often experience disconnects.
Remember to close the TCP when connecting to public networks if you want to feel safe. You can do the following or simply restart the device:
su
setprop service.adb.tcp.port -1
stop adbd
start adbd
Update :
Starting from Android Studio Bumblebee (2021.1.1) Stable, you can debug over Wifi just pairing the device by just scanning the QR code.
Quoting from the blog post :
ADB over Wi-Fi: Bumblebee includes a simplified flow to connect to
your Android 11 and higher devices over Wi-Fi for deployment and
debugging using ADB. After you enable debugging over Wi-Fi on your
device, select the Pair using Wi-Fi action in the Physical tab of the
new Device Manager to open the pairing wizard. Then follow the steps
provided to pair to a device connected over the same network. Learn
more.
Old post :
With new Android 11 you can debug your apps over WiFi without using an USB cable at all.
Quoting from Android Studio User Guide
Connect to a device over Wi-Fi (Android 11+)
Android 11 and higher support deploying and debugging your app
wirelessly from your workstation using Android Debug Bridge (adb). For
example, you can deploy your debuggable app to multiple remote devices
without physically connecting your device via USB. This eliminates the
need to deal with common USB connection issues, such as driver
installation.
To use wireless debugging, you need to pair your device to your
workstation using a pairing code. Your workstation and device must be
connected to the same wireless network. To connect to your device,
follow these steps:
On your workstation, update to the latest version of the SDK Platform-Tools.
On the device, enable developer options.
Enable the Wireless debugging option.
On the dialog that asks Allow wireless debugging on this network?, click Allow.
Select Pair device with pairing code. Take note of the pairing code, IP address, and port number displayed on the device (see image).
On your workstation, open a terminal and navigate to android_sdk/platform-tools.
Run adb pair ipaddr:port. Use the IP address and port number from step 5.
When prompted, enter the pairing code that you received in step 5. A message indicates that your device has been successfully paired.
none
Enter pairing code: 482924
Successfully paired to 192.168.1.130:37099 [guid=adb-235XY]
(For Linux or Microsoft Windows only) Run adb connect ipaddr:port. Use the IP address and port under Wireless debugging.
I found my answer here:
Connect Android device and adb host computer to a common Wi-Fi network accessible to both. We have found that not all access points are suitable; you may need to use an access point whose firewall is configured properly to support adb.
Connect the device with USB cable to host.
Make sure adb is running in USB mode on host.
$ adb usb
restarting in USB mode
Connect to the device over USB.
$ adb devices
List of devices attached
######## device
Restart host adb in tcpip mode.
$ adb tcpip 5555
restarting in TCP mode port: 5555
Find out the IP address of the Android device: Settings -> About tablet -> Status -> IP address. Remember the IP address, of the form #.#.#.#.
sometimes its not possible to find the IP-address of the android device, as in my case. so u can get it using adb as the following:
$ adb shell netcfg
and the should be in the last line of the result.
Connect adb host to device:
$ adb connect #.#.#.#
connected to #.#.#.#:5555
Remove USB cable from device, and confirm you can still access device:
$ adb devices
List of devices attached
#.#.#.#:5555 device
You're now good to go!
If the adb connection is ever lost:
Make sure that your host is still connected to the same Wi-Fi network your Android device is.
Reconnect by executing the "adb connect" step again.
Or if that doesn't work, reset your adb host:
adb kill-server
and then start over from the beginning.
The adb utility does have the ability to connect to a device over TCP/IP. However, adbd is not normally listening for TCP connections.
If you want to get it running, you need an engineering device (in other words, you need root). Then follow the directions in this post:
How can I connect to Android with ADB over TCP?
Since this only works on eng devices, it's not officially supported. Use at your own risk, expect bugs, etc.
For all , this , there exists a better method (EASIEST METHOD) :
1 ) A plugin for Android studio exits , called Android wifi ADB
2) Go to file -> settings -> Plugins -> Browse Repositories
3) Look for Android WiFi ADB , click on INSTALL , and then restart on prompt
4) You will see a new icon , which is your new plugin .
Now to make this work :
5) Go to your phone's developer option and enable DEBUGGING (must)
6) Also enable , ALLOW DEBUG OVER TCP/NETWORK
7) Attach your phone via USB , and make sure , both phone and your pc/laptop are connected to the same network (either hotspot or wifi)
8) CLICK ON THE NEW ICON (ie your ANDROID Wifi ABD)
9) Your phone get's detected and get's connected over wifi/hotspot , and hence now you may disconnect the usb . This is a one time process , hence you may not need to keep phone connected over usb .
This will save your phone from irregular charges and also , a remedy for short length usb cables .
In Developer options of Android 11, there is Wireless debugging. Make sure your laptop and phone under same network then execute 2 command below. Note that, the port for pair is different to the port for connect and you just need to pair on the first time (later you just need connect).
adb pair ipaddr:port
adb pair 192.168.1.6:42049
// will output
Enter pairing code: 696686
Successfully paired to 192.168.1.6:42049 ...
adb connect ipaddr:port
adb connect 192.168.1.6:37203
// will output
connected to 192.168.1.6:37203
Addition
These command will only work on android studio terminal, if you are in "platform-tools" directory. cd C:\Users\username\AppData\Local\Android\Sdk\platform-tools>
Install plugin Android WiFi ADB
Download and install Android WiFi ADB directly from Android Studio:
File > Settings->Plugins->Browse Repositories-> Android WiFi ADB ->Install ->Connect with cable for first time -> Click on "Connect" -> Now remove cable and start doing debug/run.
Check ss for your reference :
If you are using Android 11 click on the build version many times to activate the developer option then go to Settings>Advanced>Developer options. Scroll to debugging and turn on the "Wireless debugging" checkbox. Then open the menu debugging by touching the "Wireless debugging". Select "Pair device with paring code" and you will see the address for pairing with a pairing code. write this command in your desktop terminal to pair with your Android device.
adb pair 192.168.XXX.XXX:XXXX <--------- the address showing on screen under paring code
Use the paring code to connect.
But wait we are not connected to adb yet.
After you have successfully paired your device once. You can connect your adb anytime you turn on your Wireless debug option. To connect your adb every time before you use it from now on you don't need the pairing address anymore instead you will use the given address that shows when you enter the Wireless debug menu.
adb connect 192.168.XXX.XXX:XXXX <--- this address shows inside wireless debug menu
After a long search I found :
I must run
adb connect <device_ip_address>:5555
after disconnecting USB.
I wrote a shell script which can let you debug an Android device via Wi-Fi.
Here is the code:
#!/usr/bin/env bash
#Notice: if unable to connect to [ip]:5555,
#try adb kill-server then try again.
adb shell ip route > addrs.txt
#Case 1:Nexus 7
#192.168.88.0/23 dev wlan0 proto kernel scope link src 192.168.89.48
#Case 2: Smartsian T1,Huawei C8813
#default via 192.168.88.1 dev eth0 metric 30
#8.8.8.8 via 192.168.88.1 dev eth0 metric 30
#114.114.114.114 via 192.168.88.1 dev eth0 metric 30
#192.168.88.0/23 dev eth0 proto kernel scope link src 192.168.89.152 metric 30
#192.168.88.1 dev eth0 scope link metric 30
ip_addrs=$(awk {'if( NF >=9){print $9;}'} addrs.txt)
echo "the device ip address is $ip_addrs"
echo "connecting..."
rm addrs.txt
adb tcpip 5555
adb connect "$ip_addrs"
Following steps are standard ones to follow( mostly same as previous answers):-
adb tcpip 5555.
adb connect your_device_ip_address.
adb devices (to see if devices got connected).
But in some cases above steps gives error like "unable to connect to device. Make sure that your computer and your device are connected to the same WiFi network." And you notice the devices are already on the same network.
In this case, install this plugin "Wifi ADB Ultimate" and follow below steps.
Connect the device once through USB.
Refresh the list to check whether its connected.
Go to About Phone > Status > IP Address and note your IP address(e.g. 198.162.0.105).
Come back to Android Studio and fill in this IP as done in below photo and hit the run button.
Now, you are good to go!
To complete the answer of #usethe4ce, if you have more than one device or emulators, the adb tcpip 5555 will give error: more than one device/emulator.
In this case you need to give the serial number of the desired device:
adb devices
List of devices attached
33001229 device
emulator-5554 device
adb -s 33001229 tcpip 5555
Find your device's IP in my case I can find it from the device's wifi connected settings.
adb connect xxx.xxx.xxx.xxx:5555
For Windows:
Step 1. Make a batch file with the below commands and call the file w.bat.
Step 2. Copy the below contents in w.bat, and save it in any of the folders which are in %path% of your Windows system
echo ***Get phone in Wi-Fi mode***
echo ***Get phone in Wi-Fi mode***
adb devices
echo ***Remove cable from the phone now***
adb tcpip 9000
adb connect 192.168.1.1:9000
adb connect 192.168.1.2:9000
adb connect 192.168.1.3:9000
adb connect 192.168.1.4:9000
adb connect 192.168.1.5:9000
adb connect 192.168.1.6:9000
//<-- Till here -->
Step 3. Connect your phone and PC with a cable
Step 4. Ensure the phone is in Wi-Fi mode
Step 5. Remove the cable when the batch file tells you to
Step 6. Type w.bat on the Windows prompt (start -> run -> type CMD, press Enter) (black screen is Windows DOS prompt), if you copied it in one of the path folders then you can run from anywhere, else run from the folder where you created this file.
The output of the batch file will be something like this:
C:\Windows\System32>w
C:\Windows\System32>echo ***Get phone in Wi-Fi mode***
***Get phone in Wi-Fi mode***
C:\Windows\System32>echo ***Get phone in Wi-Fi mode***
***Get phone in Wi-Fi mode***
C:\Windows\System32>adb devices
List of devices attached
d4e9f06 device
C:\Windows\System32>echo ***Remove cable from the Phone now***
***Remove cable from the Phone now***
C:\Windows\System32>adb tcpip 9000
restarting in TCP mode port: 9000
C:\Windows\System32>adb connect 192.168.1.1:9000
unable to connect to 192.168.1.1:9000:9000
C:\Windows\System32>adb connect 192.168.1.2:9000
connected to 192.168.1.2:9000
C:\Windows\System32>adb connect 192.168.1.3:9000
unable to connect to 192.168.1.3:9000:9000
C:\Windows\System32>adb connect 192.168.1.4:9000
unable to connect to 192.168.1.4:9000:9000
C:\Windows\System32>adb connect 192.168.1.5:9000
unable to connect to 192.168.1.5:9000:9000
C:\Windows\System32>adb connect 192.168.1.6:9000
unable to connect to 192.168.1.6:9000:9000
Note 1: Find this in the output, (ignore all ->unable to connect<- errors)
connected to xxx.xxx.x.x:9000
If you see this in the result, just remove the cable from PC and go to Eclipse and run to install the app on the device; that should be it.
Note 2: DISCONNECT OR TO SWITCH WIRELESS MODE OFF: Type the below command. It should say restarting in USB mode - at this stage PC and computer should NOT be connected with a cable:
C:\Users\dell>adb usb
restarting in USB mode
Note 3: Steps to find the IP address of the phone (taken from Stack Overflow)
Find IP address of MY PHONE:
a. Dial *#*#4636#*#* to open the Testing menu.
b. In the Wi-Fi information menu: click Wi-Fi Status
c. Wi-Fi status can be blank for the first time
d. Click Refresh Status
e. In the IPaddr: <<IP ADDRESS OF THE PHONE IS LISTED>>
Note 4: My Phone Wi-Fi connection IP address range typically is as the mentioned IP addresses below,
192.168.1.1
192.168.1.2
192.168.1.3
192.168.1.4
192.168.1.5
192.168.1.6
Note 5: if you get any other sequence of IP addresses which keep getting reassigned to your phone, you can just change the IP address in the w.bat file.
Note 6: This is a brute-force method, which eliminates all manual labor to keep finding IP address and connecting to Eclipse / Wi-Fi.
SUCCESS Note 7: So in short, the regular activity would be something like this:
Step 1. Connect PC and Wi-Fi via a cable
Step 2. Start CMD - to go to Windows DOS prompt
Step 3. Type "w"
Step 4. Find connected command in the output
Step 5. Success, remove cable and start using Eclipse
Best and super easy way to do this is:-
Make a batch file :-
adb devices
adb tcpip 5555
adb connect 192.168.9.120:5555 ( Your phone ip xxx.xxx.x.xxx:5555 )
Place this file into your android sdk platform-tool folder.
Example:- C:\Users\'user_name'\AppData\Local\Android\Sdk\platform-tools
Right click file > sendto > Desktop(create shortcut )
That's it....
Now you just need to connect your phone through USB , then open desktop shortcut and disconnect your phone...
Though there are so many good answers, here is my two cents for the future me :P and for anyone who wants it quick and easy.
For Mac:
connect the device using USB first and make sure debugging is working. Disconnect any other devices and quit emulators.
open terminal and run the following script
adb tcpip 5555
adb connect $(adb shell ifconfig | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}' | cut -d: -f2):5555
disconnect USB connection and the device should be available for WiFi debugging
Explanation:
adb tcpip 5555 commands the device to start listening for connections on port 5555
adb connect $(_ip_address_fetched_):5555 tells to connect on port 5555 of the _ip_address_fetched_ address
where _ip_address_fetched_ includes following:
adb shell ifconfig getting internet configurations using adb shell
grep "inter " filter any line that starts with inter
grep -v 127.0.0.1 exclude localhost.
At this point, output should be like:
inet addr:###.###.#.### Bcast:###.###.#.### Mask:255.255.255.0
awk '{print $2}' get the second part of the components array, separated by space (I'm using zsh).
The output up to this point is
addr:###.###.#.###
cut -d: -f2 split the string by delimiter : and take second part. It will only take your device IP address
In Device Settigs-> "Developer options" -> "Revoke USB debugging authorizations".
Connect the device via USB and make sure debugging is working.
adb tcpip 5555
adb connect <DEVICE_IP_ADDRESS>:5555
Disconnect USB
adb devices
From search and from some answers i use this method and it work fine
and you must know that tcpip is not always 5555 , you must find it just follow this
you need first to download platform-tools
https://developer.android.com/studio/releases/platform-tools.html
extract platform-tools folder to C drive and run Powershell there (Right click >> PowerShell >> Open here)
#Connect phone with usb cable
PS C:\platform-tools> adb kill-server
PS C:\platform-tools> adb shell ip route > addrs.txt
#this give you your tcpip
* daemon not running; starting now at tcp:5037
* daemon started successfully
PS C:\platform-tools> adb tcpip 5037
restarting in TCP mode port: 5037
#Disconnect phone
#adb connect <phone_ip>:5037
PS C:\platform-tools> adb connect 192.168.43.1:5037
connected to 192.168.43.1:5037
Now you can see your phone in Android studio
>## open command prompt with Run as Administrtor ##
adb connect ipdevice:5037
The best way is using ADBConnect (Eclipse plugin) and ADB Wireless (app for Android device).
For Ubuntu / Linux:
Make sure your device is working for debugging: http://developer.android.com/tools/help/adb.html#Enabling
Go to your sdk folder and find the folder platform-tools
Use ./adb devices to list the connected devices. Make sure it is only one device connected and no emulator running.
Find your device IP address, you can find it in your device:
http://developer.android.com/tools/help/adb.html#wireless, or got adb shell like this: ./adb shell then netcfg. You will see a list of IP addresses. Find wlan0, in my case 192.168.100.3/2.
./adb tcpip 5555
Finally enter ./adb connect <Your device IP Address>:5555 in your terminal. You can now deploy the application to your device over Wi-Fi.
Note :- Android Phone must be rooted and no need of usb cable.
Install wifi adb in android phone from playstore
link :-https://play.google.com/store/apps/details?id=com.ttxapps.wifiadb
For Windows
I am using this technique , which is very easy.
1) download adb :
link : https://www.dropbox.com/s/mcxw0yy3jvydupd/adb-setup-1.4.3.exe?dl=0
2) Run exe :- when you see blue screen press y enter .
3) Now open your wifi adb apk , just grant root permission and must be remember you android phone and system on the same network by wifi or hotspot .
4) Open Wifi adb apk , you will get some ip address like , adb connect 192.168.2.134:5555
Note this ip may be very from system to system , now put this information to your command prompt and hit Enter .
5) Open cmd from anywhere enter adb connect 192.168.2.134:5555 .
6) Finally you successfully connected to adb . it will show message like
connected to 192.168.2.140:5555
For Mac Os
This is the easiest way and will provide automatic updates.
1)Install homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2)Install adb
brew cask install android-platform-tools
3)Start using adb
adb devices
4) Open Wifi adb apk , you will get some ip address like , adb connect 192.168.2.134:5555 Note this ip may be very from system to system , now put this information to your terminal and hit Enter .
5) Open terminal in mac os from anywhere enter adb connect 192.168.2.134:5555 .
6) Finally you successfully connected to adb . it will show message like connected to 192.168.2.140:5555
I hope its help you ,Thank You !
If you are a windows user and your android sdk is located at C:\Users\%username%\AppData\Local\Android\Sdk then you can follow this method. If your andoid sdk not located there, replace that path to the below code.
#echo off
"C:\Users\%username%\AppData\Local\Android\Sdk\platform-tools\adb.exe" disconnect
"C:\Users\%username%\AppData\Local\Android\Sdk\platform-tools\adb.exe" shell ip route > %temp%\addrs12321.txt
For /F "UseBackQ Delims==" %%A In ("%temp%\addrs12321.txt") Do Set "lastline=%%A"
FOR %%C IN (%lastline%) DO SET last=%%C
"C:\Users\%username%\AppData\Local\Android\Sdk\platform-tools\adb.exe" tcpip 5555
"C:\Users\%username%\AppData\Local\Android\Sdk\platform-tools\adb.exe" connect %last%:5555 > %temp%\adbresult.txt
set /p result=<%temp%\adbresult.txt
del /f %temp%\addrs12321.txt
echo MSGBOX "%result%" > %temp%\TEMPmessage.vbs
call %temp%\TEMPmessage.vbs
del %temp%\TEMPmessage.vbs /f /q
del %temp%\adbresult.txt /f /q
Step 1.
Turn on usb debugging,
Connect your phone to windows machine
select file transfer in usb options menu in android menu (if found)
Step 2.
copy above code
save as its extension like .bat, eg filename.bat
double click on the file you saved. done
note you can connect any time by running that file while the device
being connected with the pc with usb debugging is turned on.
One imp point probably missed here - once you do a adb remount - the TCP connection is lost hence you have to do a adb connect IP:port once over again
Connect the device via USB and make sure debugging is working. these steps are taken if you already have installed adb and set it's path in environment varialbe
open cmd and type the following
adb tcpip 5555
find the IP address with adb shell ip route
adb connect DEVICE_IP_ADDRESS:5555
Disconnect USB and proceed with wireless debugging.
I wrote a simple script for Windows:
Step 1. Make a batch file with the below commands and call the file wifi_dedug.bat and copy the below contents:
adb tcpip 5555
pause
adb shell "ip addr show wlan0 | grep 'inet ' | cut -d' ' -f6|cut -d/ -f1" > tmpFile
pause
set /p ip= < tmpFile
#echo %ip%
del tmpFile
#echo %ip%
adb connect %ip%
pause
Step 2. connect your device to pc.
Step 3. start batch file (key enter when requested)
Step 4. disconnect your device and deploy/debug via wifi.
1- For this I am considering you have already installed the latest version of Android studio. If not you can download it from here.
2 - You can set the platform tools path in environment variable (optional).
3 - Make sure your device and pc connected to same network.
plug in the data cable from pc to device.
Now, type adb tcpip 5555
remove data cable.
Then type adb connect 192.168.43.95
here 5555 is the port number and 192.168.43.95 is the ip address of the mobile device you can get id address from the mobile settings .
Then go to About device and go to status you can see the ip address of the device.
You can connect multiple device from different ports which can give ease in development.
Or you can go to this link for brief description with screenshots. http://blogssolutions.co.in/connect-your-android-phone-wirelessly-by-adb
Edit August 2021
Google removed it with ArcticFox Beta 03 https://issuetracker.google.com/issues/190411383 but in Android Studio Bumblebee it's still there. It looks like they have to much issues with it, that's why it's just in canary builds
Original post
This Android WiFi ADB plugin doesn't work in 4.1.1 (anymore)
But there is much more simple solution:
If you have an Android 11 (api30) device you should use Android Studio 2020.3.1 (Canary) to connect. It's super easy
Then you go to developer settings and scan QR code. That's it.
You can use connected device in other (older) Android Studio version now as well
Steps for Android Wifi debugging with ADB:
$> adb devices // check all usb debuggable devices connected.
$> adb -d shell // Access device shell.
shell> ifconfig // Check and copy wifi ip-address eg:192.168.1.90
shell> exit // Exit from android device shell.
$> adb tcpip 5000 // open TCP port 5000 (or any available)
$> adb connect 192.168.1.90:5000 // connect to device via wifi ip over specific TCP port.
$> adb devices // you will get debuggabled android device over wifi.
Required: Connect your android device to computer via USB with
developer mode enabled. Also connect your android device and computer
to same wifi router (or use tethering).