LinuxCommandLibrary

adb-forward

TLDR

Forward local port to device port

$ adb forward tcp:[8080] tcp:[8080]
copy
Forward to a Unix domain socket
$ adb forward tcp:[8080] localabstract:[socket_name]
copy
List all forwarded ports
$ adb forward --list
copy
Remove a specific forward
$ adb forward --remove tcp:[8080]
copy
Remove all forwards
$ adb forward --remove-all
copy

SYNOPSIS

adb forward [--no-rebind] local remote
adb forward --list | --remove local | --remove-all

DESCRIPTION

adb forward sets up port forwarding from a local port on your computer to a port on the connected Android device. This enables connecting to services running on the device as if they were running locally.
Common uses include debugging apps with remote debuggers, accessing development servers running on the device, or connecting to app-specific sockets.

PARAMETERS

tcp:port

TCP port number
localabstract:name
Unix domain socket in abstract namespace
localreserved:name
Unix domain socket in reserved namespace
localfilesystem:name
Unix domain socket in filesystem namespace
jdwp:pid
JDWP (Java Debug Wire Protocol) for process ID
--no-rebind
Fail if local port is already forwarded
--list
List all active port forwards
--remove local
Remove specific forward rule
--remove-all
Remove all forward rules

CAVEATS

Port forwards persist until removed, the device disconnects, or the adb server restarts. Both local and remote ports must be available. Firewalls may block forwarded connections.

HISTORY

Port forwarding has been a core adb feature since Android's initial release in 2008, essential for remote debugging of Android applications through JDWP and other protocols.

SEE ALSO

adb(1), adb-reverse(1)

Copied to clipboard