Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable adb port forwarding?

Tags:

android

adb

How do I disable a port forwarding rule in adb that was previously enabled with

    adb forward tcp:1234 tcp:1234

Is there any other way than killing and restarting the adb server?

like image 287
Olafur Helgason Avatar asked Oct 03 '12 23:10

Olafur Helgason


2 Answers

Try adb forward --remove tcp:8080, or adb forward --remove-all.

This was added to adb in December 2012

like image 30
stefanogreg Avatar answered Oct 24 '22 14:10

stefanogreg


Setting Up Redirection through ADB

The Android Debug Bridge (ADB) tool provides port forwarding, an alternate way for you to set up network redirection. For more information, see Forwarding Ports in the ADB documentation.

You can also remove a redirection by killing the ADB server.

However you can use network redirection provided by emulator console, which provide ways of removing. To access type:

telnet localhost emulator_port

usually first emulator runs on port 5554.

use command "rdir" to add, del or list network redirections.

See documentation in Using Network Redirection.

Good luck.

EDIT:

To stop forwarding use

adb forward --remove tcp:<port>, or adb forward --remove-all.

This was added to adb in December 2012 (see patch here). The SDK update released for Android 4.3 (API 18) was the first to support it.

like image 149
Luis Avatar answered Oct 24 '22 13:10

Luis