Skip to content

Instantly share code, notes, and snippets.

@SuggonM
Last active February 23, 2026 14:59
Show Gist options
  • Select an option

  • Save SuggonM/82c983a8b408019d2d1211ffa3aecef0 to your computer and use it in GitHub Desktop.

Select an option

Save SuggonM/82c983a8b408019d2d1211ffa3aecef0 to your computer and use it in GitHub Desktop.
Restart wireless debugging (ADB) in port 5555 with Termux (no root)
#!/data/data/com.termux/files/usr/bin/bash
termux-notification --id 1 -t "Scanning for ADB port..."
adb_port=$(nmap -sT -p30000-50000 --open localhost | grep -m1 -oP "^\d+")
if [[ -z $adb_port ]]; then
termux-notification --id 1 -t "No debug port detected" -c "Tap to rescan." --action "$(realpath $0)"
exit
fi
termux-notification --id 1 -t "ADB port detected: $adb_port. Restarting ADB..."
adb connect localhost:$adb_port
adb tcpip 5555
adb disconnect
adb shell settings put global adb_wifi_enabled 0
termux-notification --id 1 -t "Successfully restarted ADB in port 5555"
@SuggonM
Copy link
Author

SuggonM commented Feb 23, 2026

Can't find how to add description to gists so here's the gist of this script:

  1. Poll through all possible wireless debugging ports
  2. Connect ADB via the discovered port
  3. Restart it in port 5555
  4. Disconnect the port found earlier
  5. Disable wireless debugging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment