Adb reverse tcp not working on android connected remotely
Asked Answered
B

4

24

I am trying to execute reverse tcp command on a android device connected remotely(using adb connect <ip-address>). But I am getting following error while executing:

adb -s 192.168.0.101 reverse tcp:8081 tcp:8081
error: more than one device/emulator

but I have only one device connected.

adb devices
List of devices attached
192.168.0.101:5555      device

same command works fine if I connect my device using usb. Any Ideas ?

Beforehand answered 10/9, 2017 at 8:31 Comment(1)
got the same! adb forward is working, but adb reverse is not! Did you solve it?Wheelbase
P
16

I just came across this, and while none of the answers worked I eventually got it working repeatably. Following these steps should get you wirelessly debugging your React Native app on your real Android device.

I ran adb kill-server && adb start-server first. I'm not sure if that's strictly necessary.

  1. Connect your phone and computer to the same network
  2. Connect your phone to your computer via USB
  3. adb tcpip 5555
  4. adb reverse tcp:8081 tcp:5555
  5. adb connect YOUR.PHONE.IP.ADDRESS:5555

You can find your phone's wifi IP address from Network Settings -> Wifi -> Wifi Preferences -> IP Address.

  1. Disconnect the USB wire.
  2. If the app isn't yet installed, install the app on your phone the way you usually do over USB, react-native run android for most cases.

Open the app, and you get an “Unable to load Script” error. Pressing ‘Reload’ gives an error “Could not connect to development server.” Overcome your despair and push onwards.

  1. Open the developer menu (shake the phone with your React Native app open) and select “Dev Settings”. Select “Debug server host & port for device” from the menu. Find your computer’s ip address. Enter that in the window on your phone, followed by the port number 8081: YOUR.COMPUTER.IP.ADDRESS:8081
  2. Now shake and reload.  Sometimes this doesn’t do anything, so closing the app and reopening does the trick.

At this point, you should see the bundler loading up with the familiar green bar.

  1. shake and hit “debug js remotely”.

From here you should have your normal debugging experience, minus the wire.

Pierpont answered 19/2, 2020 at 16:20 Comment(3)
in step 4, should the second socket be tcp:5555 or tcp:8081 ?Rudie
@Rudie My understanding is as follows: The 2nd socket in step 4 is the socket on your phone you want to bridge to. I chose 5555 in step 3, so that's what my phone is listening to. That's what I need to use as the 2nd socket in step 4 as well as in step 5.Pierpont
This works! Step 4 is not neededRaila
B
6
adb kill-server

adb start-server

adb reverse tcp:8081  tcp:8081
Bunni answered 2/5, 2022 at 4:22 Comment(1)
While this code may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please edit your answer to add explanations and give an indication of what limitations and assumptions apply.Gooden
N
2

I found that if I'm doing a TCP/IP connection, I need to set the reverse command before I connect to the remote device

Example:

adb tcpip 5555
adb reverse tcp:8081 tcp:8081
adb connect 192.168.1.113

If I connect before performing the reverse, I would always get the error about multiple devices/emulators

Nerti answered 5/4, 2019 at 18:2 Comment(2)
If set the reverse command before connecting to the remote device, the port forwarding only work in usb mode and not the tcp mode. If you want the port forwarding works in tcp mode, you have to run it after the adb connect command.Raila
why do you add 5555 and then connect to 8081? That doesnt make senseUmlaut
A
0

I think your server device is blocked by the firewall

in Windows: Go to

Windows Firewall -> Allow app or feature through Windows Defender Firewall -> Change Settings -> Allow another app... Choose your Web Server

in Linux / Debian:

sudo allow [port]
Appointive answered 2/7, 2024 at 1:39 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Rictus

© 2022 - 2025 — McMap. All rights reserved.