Android
ADB
TCP
Remote Debugging
Networking

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.

Practice system design

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:

  1. connect the device with USB
  2. switch ADB to TCP mode
  3. 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:

bash
adb version
adb devices

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.

bash
1adb devices
2adb tcpip 5555
3adb shell ip -f inet addr show wlan0
4adb connect 192.168.1.25:5555
5adb devices

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.

bash
1adb pair 192.168.1.25:37129
2# enter the pairing code shown on the device
3
4adb connect 192.168.1.25:5555
5adb devices

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:

  1. confirm the device and host are on the same local network
  2. confirm the device IP address has not changed
  3. confirm Wireless debugging or TCP mode is still enabled
  4. confirm no firewall or VPN is blocking local traffic
  5. reset the local ADB server state

A quick reset sequence often clears stale state:

bash
1adb disconnect
2adb kill-server
3adb start-server
4adb connect 192.168.1.25:5555
5adb devices

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:

  1. enable wireless debugging only for active work
  2. avoid untrusted or public networks
  3. disconnect when the session is finished
  4. 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.

bash
adb -s 192.168.1.25:5555 shell getprop ro.product.model
adb -s 192.168.1.25:5555 shell pm list packages | head
adb -s 192.168.1.25:5555 logcat -d | head

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 tcpip flow 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 -s once the connection is established.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track 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.

Practice system design

All Rights Reserved.