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.
Introduction
ADB over TCP lets you debug an Android device without leaving a USB cable attached, which is useful for testing, demos, and shared lab setups. The main confusion is that there are now two different workflows: the older adb tcpip method and the newer wireless-debugging pairing flow on modern Android versions.
Choose the Correct Wireless Debugging Method
Older guides often assume the classic USB-first flow:
- connect the device with USB
- switch ADB to TCP mode
- connect to the device IP and port
Newer Android releases support Wireless debugging in Developer options, which uses pairing and is usually the better choice. Before doing anything else, verify the host tools:
If platform-tools are very old, the pairing workflow may fail or produce misleading errors.
Legacy USB to TCP Flow
The classic method still works on many devices. Start with a normal USB connection, then tell the device’s ADB daemon to listen on a TCP port.
Once the TCP connection is visible in adb devices, you can unplug USB and continue using the network connection. This is simple, but it leaves the device listening on that port until the mode is changed again or the device resets the ADB daemon.
Modern Wireless Debugging Pairing Flow
On newer Android versions, enable Developer options and turn on Wireless debugging. The device will show a pairing code and a pairing port. Use that pair command first, then connect to the regular debug port.
The pairing port and the debug port are not always the same. Mixing them up is one of the most common reasons the connection looks “closed” even though the device is visible on the network.
Troubleshoot Closed, Refused, or Timeout Errors
When adb connect fails, check the environment in a strict order:
- confirm the device and host are on the same local network
- confirm the device IP address has not changed
- confirm Wireless debugging or TCP mode is still enabled
- confirm no firewall or VPN is blocking local traffic
- reset the local ADB server state
A quick reset sequence often clears stale state:
If that still fails, reconnect over USB and repeat the enable or pairing process from the beginning.
Corporate Networks and Hotspots
A lot of “ADB over Wi-Fi is broken” reports are actually network-policy problems. Some corporate networks enable client isolation, which prevents laptops and phones on the same SSID from talking directly to each other. VPN clients can also interfere by changing routing rules for local traffic.
In those cases, a developer hotspot or a known-good lab network is often the fastest fix. It is worth documenting one stable network setup for teams that use wireless debugging regularly.
Use It Safely
ADB gives deep access to the device, so wireless access should be treated like privileged debugging, not like a background convenience feature. A reasonable practice is:
- enable wireless debugging only for active work
- avoid untrusted or public networks
- disconnect when the session is finished
- disable the feature when you are done
That reduces the chance of accidental or unauthorized connections, especially on shared devices.
Verify the Session With Real Commands
Once connected, run a couple of short commands to confirm the session is actually usable.
When multiple devices are attached, always use -s so install or log commands do not hit the wrong target.
Common Pitfalls
The most common mistake is following an old adb tcpip guide on a device that expects the pairing workflow. Another is forgetting that the phone’s IP address can change when Wi-Fi reconnects. Developers also lose time debugging ADB itself when the real problem is client-isolated Wi-Fi or a VPN that blocks local routes.
Summary
- Use either the legacy
adb tcpipflow or the modern pairing flow, depending on the Android version and policy. - Verify host tooling and device visibility before starting wireless setup.
- Check IP address, local network reachability, and ADB server state when connection attempts fail.
- Treat wireless ADB as privileged access and disable it when the session ends.
- Use explicit device targeting with
-sonce the connection is established.
Related reading
- 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 expose a service on multiple ports over HTTP in ingress?
- 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.