androidadb

adb returns "error: unknown host service" when pairing device using Scrcpy wireless debugging


I'm trying to connect my Android device to my Windows 11 PC using Scrcpy over wireless debugging with ADB, but I keep running into this error when trying to pair:

> adb pair 192.168.1.7:434223
Enter pairing code: 342322
error: unknown host service

> adb mdns check
error: unknown host service

I’ve verified that the device is on the same network, the port is correct, and the pairing code is from the developer options in Android. I've searched around, but none of the existing solutions seem to match my situation or resolve the error.

How can I fix or properly diagnose this unknown host service error when trying to use adb pair?


Solution

  • I managed to fix this after a lot of trial and error. Here's what worked for me when adb kept throwing:

    error: unknown host service

    Step-by-step solution:

    1. Ensure ADB version supports mDNS (1.0.41 or newer):
      You can check your version with:

      adb version
      
    2. Restart the ADB server (twice, yes really):

       adb kill-server
       adb kill-server
       adb start-server
      
    3. Check the mDNS status:

      adb mdns check
      

      If this still returns error: unknown host service, continue to step 4.

    4. Enable the alternative mDNS backend:

      Open a terminal as administrator, then run:

      setx ADB_MDNS_OPENSCREEN 1 /M
      
    5. Restart ADB again (see step 2).


    Notes:

    The key for me was enabling ADB_MDNS_OPENSCREEN, which tells ADB to use an alternative mDNS backend. Restarting ADB twice before starting it again seems to help make sure it fully resets.

    If the issue pops up again, just re-do the ADB restart steps. This solved the issue and allowed adb pair, adb mdns check, and Scrcpy wireless debugging to work properly.

    Hope this helps someone dodge the hours I lost to this!