adb Verified current stable Not installed? System Operations

Adb / List Forwardings

List Forwardings

Use 'adb forward --list' to inspect active port forwarding between a host machine and Android devices for debugging.

$
Terminal
adb forward --list

When To Use

Execute 'adb forward --list' during multi-device debugging sessions to verify explicit port-forwarding rules, ensuring correct routing of network requests from development tools to device instances, pivotal for applications with network dependencies.

Pro Tip

The output doesn't highlight implicit rules applied by some custom ROMs. Use 'adb shell netcfg' to cross-verify active connections.

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
List of forwardings:

    Port          Device
    -----------   -----------
    8080          tcp:8080
    8888          tcp:8888

Anatomy of Output

Understanding the result

List of forward connections: Header

Indicates the beginning of the forwarding list output.

serial-number tcp:local-port tcp:remote-port Format

Displays the format of entries; no title rows provided.

emulator-5554 tcp:8080 tcp:8080 Example Entry

Maps local port 8080 to remote port 8080 on the specified device.

Power User Variants

Optimized versions

adb -s <device-serial> forward --list

Lists forwarding rules for a specific device, narrowing the results for targeted troubleshooting.

adb forward --remove-all

Clears all existing port forwarding rules to resolve overlaps potentially causing conflicts between sessions.

adb forward --no-rebind tcp:8080 tcp:8080

Sets a port forwarding only if no previous forwarding exists; useful for legacy networks.

Unix Pipeline

Shell combinations

adb forward --list | grep 'tcp:8080'

Combines grep to filter forwarding rules specifically for port 8080, ensuring it’s correctly mapped for a certain app.

adb forward --list | awk '{print $1}' | xargs adb -s

Uses awk and xargs to iterate over specific device serials, perform a custom operation, checking health status.

Troubleshooting

Common pitfalls

adb server version (41) doesn't match this client (40); killing...

Solution: Update ADB to the matching version on both client and server to resolve compatibility issues.

failed to start daemon, error: cannot connect to daemon

Solution: Ensure no firewall or security service is blocking ADB on the host.

list-forward-protocol error EOF

Solution: Rescan USB devices using 'adb kill-server' and 'adb start-server' to refresh device connections.

Command Breakdown

What each part is doing

adb
Base Command
The executable that performs this operation. Here it runs Adb before the shell applies any redirect operators.
--list
Command Option
Tool-specific option used by this command invocation.

How To Run

Execution path

  1. Step 1

    Run the command: `adb forward --list`

  2. Step 2

    Check that the expected ports are listed in the output.

Alternative Approaches

Comparable commands in other tools

Alternative system operations tools for the same job.