I'm trying to redirect/forward a TCP port from the local machine to the device (where I have a server listening on a given port). The command I'm using is the following:
adb forward -a tcp:5555 tcp:5555
However, when I check with netstat I see that adb is only listening on 127.0.0.1. I need adb to listen on any IP not only the local host. Is this possible?
I'm developing an Android app as a side project and today I learned about adb forward and adb reverse . Basically, they allow you to forward or reverse traffic to specific ports between an Android device and your development machine.
Use option -P (Note: Caps P)to start adb server in a specific port. It will list the devices attached to this specific adb server. If the adb server is not running then it will start a new adb server with the given port number.
$ adb reverse --list. Reverse a TCP port from an emulator or device to localhost.
When the server starts, it binds to local TCP port 5037 and listens for commands sent from adb clients—all adb clients use port 5037 to communicate with the adb server.
After a while looking around this issue I finally found the solution. It seems that for whatever reason adb is not processing the "-a" option (for me it seems like a bug in adb .. but I'm not sure). The alternative, is to start the daemon server and pass this option to it as following:
adb -a nodaemon server start
Once we start the server then the tcp forward now is listening in all the interfaces instead of localhost.
[EDIT]
Some times you may get an error like:
> could not install smartsocket listener: Address already
This is because there's already an adb server running so you have to kill it before starting the new one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With