{"record":{"id":"7a2db0650c9dcb9d","repo":"MuntashirAkon/AppManager","slug":"timed-out-while-trying-to-find-a-valid-host-address-and-port","errorCode":null,"errorMessage":"Timed out while trying to find a valid host address and port","messagePattern":"Timed out while trying to find a valid host address and port","errorType":"exception","errorClass":"InterruptedException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/adb/AdbUtils.java","lineNumber":88,"sourceCode":"                atomicPort.set(port);\n            }\n            resolveHostAndPort.countDown();\n        });\n        AdbMdns adbMdnsTls = null;\n        try {\n            adbMdnsTcp.start();\n            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {\n                adbMdnsTls = new AdbMdns(context, AdbMdns.SERVICE_TYPE_TLS_CONNECT, (hostAddress, port) -> {\n                    if (hostAddress != null) {\n                        atomicHostAddress.set(hostAddress.getHostAddress());\n                        atomicPort.set(port);\n                    }\n                    resolveHostAndPort.countDown();\n                });\n                adbMdnsTls.start();\n            }\n            if (!resolveHostAndPort.await(timeout, unit)) {\n                throw new InterruptedException(\"Timed out while trying to find a valid host address and port\");\n            }\n        } catch (RuntimeException e) {\n            throw new IOException(\"Could not start ADB service discovery\", e);\n        } finally {\n            stopDiscovery(adbMdnsTcp);\n            stopDiscovery(adbMdnsTls);\n        }\n\n        String host = atomicHostAddress.get();\n        int port = atomicPort.get();\n        if (host == null || port == -1) {\n            throw new IOException(\"Could not find any valid host address or port\");\n        }\n        return new Pair<>(host, port);\n    }\n\n    private static void stopDiscovery(AdbMdns adbMdns) {\n        if (adbMdns == null) {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/adb/AdbUtils.java#L70-L106","documentation":"Timeout guard in getLatestAdbDaemon(): the CountDownLatch waiting on mDNS discovery (TCP-connect and, on P+, TLS-connect services) expired before any service resolved a host address and port, or the resolved values were null. Wireless debugging may be off, the device on a different subnet, or mDNS packets blocked — no valid endpoint was found in time.","triggerScenarios":"Thrown at app/src/main/java/io/github/muntashirakon/AppManager/adb/AdbUtils.java:88 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Increase the discovery timeout and retry","Have the user toggle Wireless debugging off/on to re-announce mDNS services","Ensure multicast/mDNS traffic is allowed on the network","Fall back to manual entry of the pairing host and port"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}