Search code examples
androidadb

adb port forwarding to listen on all interfaces


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?


Solution

  • 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 (adb kill-server) before starting the new one.