Skip to content

Instantly share code, notes, and snippets.

@SuggonM
Last active December 30, 2025 15:57
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 -s localhost:$adb_port tcpip 5555
adb kill-server
termux-notification --id 1 -t "Successfully restarted ADB in port 5555"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment