How can I connect to Android with ADB over TCP?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Android Debug Bridge (ADB) is a versatile command-line tool that allows developers to communicate with an Android device for debugging and other purposes. Typically, ADB operates through a USB connection, but it can be configured to connect over a TCP/IP connection. This connectivity method is particularly handy when USB debugging is inconvenient or impossible, such as when dealing with devices mounted in hard-to-reach places or needing to handle multiple devices simultaneously from a distance.
Prerequisites for ADB Over TCP
- Android Device: The device must be Android with developer options enabled.
- ADB Tools: Installed on your computer. ADB is part of the Android SDK platform-tools.
- Network Connectivity: Both the Android device and the PC must be on the same local network.
Steps to Connect ADB over TCP
Enabling Developer Options and USB Debugging
First, you need to activate developer options and USB debugging on your Android device:
- Go to
Settings>About phoneand tap onBuild number7 times to activate Developer Options. - Return to
Settings>System>Advanced>Developer optionsand enableUSB debugging.
Setting up ADB over TCP/IP
To set up ADB over TCP/IP, follow these detailed steps:
- Connect the device to your computer via USB:
- Ensure the device is connected to the same network as your computer.
- Open a command prompt or terminal on your computer:
- Navigate to the directory where ADB is installed if it's not added to your system's PATH.
- Check connected devices:
- Run
adb devicesto confirm your device is connected properly via USB.
- Switch ADB to TCP mode:
- Execute the command:
- Replace
<port>with a port number, typically5555.
- Disconnect the USB cable:
- Remove the device from the USB connection.
- Connect over TCP/IP:
- Find your Android device’s IP address in
Settings>About phone>StatusorWi-Fi information. - Connect by executing:
- Replace
<device-ip>with your device's IP address and<port>with the same port used earlier.
- Verify the Connection:
- Run
adb devicesagain. You should now see your device listed as connected via TCP/IP.
Troubleshooting Common Issues
Here are some common issues and their resolutions:
- Device not found: Ensure both devices are on the same network and the correct IP address and port are being used.
- Connection refused: Check if your Android device’s port is correctly set and listening. You might restart ADB in TCP mode and reconnect.
- ADB not recognized: Ensure ADB is properly installed and your PATH environment variable includes the folder where ADB is installed.
Disconnection and Reverting to USB
To disconnect, simply use:
Reverting back to USB mode can be done by connecting the device via USB and running:
Summary Table
| Action | Command/Location | Notes |
| Enable USB Debugging | Settings > Developer options | Developer options must be enabled first. |
| Start ADB over TCP | adb tcpip <port> | <port> is usually 5555. |
| Connect to the Device | adb connect <device-ip>:<port> | Ensure the device and PC are on the same network. |
| Disconnect | adb disconnect <device-ip>:<port> | Useful to cleanly stop the TCP connection. |
| Revert to USB | adb usb | Ensures connection is set back to USB. |
Conclusion
ADB over TCP/IP offers a flexible way to manage Android devices remotely, bypassing the need for a physical connection via USB. This can be exceptionally useful for developers testing apps on multiple devices simultaneously or when physical access to the device is limited. By following the steps and guidelines provided, setting up ADB over TCP should be straightforward, enhancing your development and debugging workflow.
Related reading
- How can I connect to Android with ADB over TCP?
- How can I create a Route 53 Record to an ALB? AWS
- How can I create an Android booking system which is linked to a PC based server program?
- How can I determine an appropriate pod CIDR value for a Kubernetes cluster?
- How can I convert a String to an MD5 hash in iOS using Swift?
- How can I convert a String to an MD5 hash in iOS using Swift?
- How can I corral a method which may contain it's own async calls without having write access to the file?
- How can I deal with floating point number precision in JavaScript?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.