Why the Wireless Debugging Port Changes (and How to Fix It)
The Wireless debugging port changes every time you turn it on or restart. Why Android does it, how to find the new port with adb mdns, and a fixed-port workaround.
The Wireless debugging port changes because Android picks a random free port every time adbd starts listening: each time you switch Wireless debugging on, after every restart, and sometimes when Wi-Fi reconnects. There is no setting to fix it. Instead of typing the port, let the tool find it on the network (mDNS), or, if you really need a fixed port, switch the phone to the older adb tcpip mode, which has its own downsides. Your pairing is not affected: only the port is new.
Two ports, both temporary
Wireless debugging uses two different ports, and both change:
| Port | Where you see it | Used for | How long it lives |
|---|---|---|---|
| Pairing port | The "Pair device with pairing code" dialog | adb pair, once per device | Only while that dialog is open |
| Connect port | IP address & Port at the top of the Wireless debugging screen | adb connect, every session | Until Wireless debugging turns off |
So adb connect 192.168.1.20:41237 works today, and tomorrow the same phone says 192.168.1.20:39553. The IP can change too if your router hands out a new address.
Why Android does this
Wireless debugging was added in Android 11 with security in mind:
- A random port is harder to find. A fixed, well-known port such as 5555 is the first thing anyone scanning a network tries.
- No port conflicts. The phone takes whatever port is free right now instead of fighting other apps for one number.
- The port is not the secret. Security comes from pairing (TLS with keys exchanged through the code), so Android does not need the port to stay the same. Tools are expected to discover it.
Android also switches Wireless debugging off after a restart and when you leave the network, so a new port each time is part of the same design. See Wireless debugging keeps turning off.
Find the current port without looking at the phone
The phone announces its connect service on the local network with mDNS (Bonjour), as _adb-tls-connect._tcp. While the pairing dialog is open it also announces _adb-tls-pairing._tcp. On a computer:
adb mdns check
adb mdns servicesExample output:
List of discovered mdns services
adb-R58M12ABCDE-x1Yz9Q _adb-tls-connect._tcp 192.168.1.20:41237Recent platform-tools also connect to paired phones found this way by themselves, so adb devices may show the phone without any adb connect. If adb mdns services stays empty, your network or router is blocking multicast. Guest networks and some mesh systems do this. Typing the IP and port from the phone's screen still works.
Android Studio's "Pair devices using Wi-Fi" uses the same discovery, which is why it never asks for a port.
The fixed-port workaround: adb tcpip
If a script or tool insists on a fixed port, you can switch adbd into the classic TCP mode on port 5555 over the wireless connection you already have:
adb connect 192.168.1.20:41237
adb tcpip 5555
adb connect 192.168.1.20:5555From then on the phone listens on 5555. It works, but know what you give up:
| Wireless debugging | adb tcpip 5555 | |
|---|---|---|
| Port | Random, changes | Fixed 5555 |
| Encryption | TLS | None |
| Who can connect | Paired devices only | Any computer you accept at the "Allow USB debugging?" prompt |
| After a restart | Off, port changes | Off, needs Wireless debugging or USB again |
| Shown in Settings | Yes | No visible switch |
The fixed port still disappears at the next restart, so you gain less than it seems. Do not leave tcpip mode on over public Wi-Fi. More in adb tcpip vs Wireless debugging.
Other tricks you will find online, such as setting service.adb.tls.port or service.adb.tcp.port with setprop, need root on normal phones.
Fix the IP address too
If your scripts also hard-code the IP, give the phone a DHCP reservation (often called "static lease" or "address reservation") in your router's settings. The port will still change, but the address will not, which makes adb mdns services output easier to match.
On many phones, Wi-Fi uses a random MAC address per network. Use the MAC shown for that network in the phone's Wi-Fi details when you set the reservation, or the router will not recognise it.
How ADB Kit avoids the problem
ADB Kit runs on the phone and connects to the phone's own adbd. It never asks you for a port:
- During pairing, it finds the pairing service itself, so you only type the six-digit code.
- After that, it looks up the connect service by name whenever Wireless debugging is switched on, and reconnects by itself on the new port.
- For other phones added with Add phone, it also looks the phone up by its service name first, so a phone whose port changed is found again.
If a phone is not found, check that both are on the same Wi-Fi and that Wireless debugging is on. ADB Kit tells you to turn on that phone's Wireless debugging when it cannot reach another phone, or Turn on Wireless debugging to reconnect. for this one.
Common questions
Can I set a fixed port in Developer options? No. Stock Android has no such setting on any brand we know of.
Does a new port mean I have to pair again? No. Pairing is stored per device and survives port changes, restarts and Wireless debugging being switched off.
Why does adb connect say "Connection refused" with yesterday's port? Nothing listens there any more. Read the new port from the screen or adb mdns services. See fix adb connect: Connection refused.
Is the port the same as 5555? Only in tcpip mode. Wireless debugging almost never uses 5555.