{"record":{"id":"4498df9369d37562","repo":"quarkusio/quarkus","slug":"unable-to-look-up-srv-record-for-host","errorCode":null,"errorMessage":"Unable to look up SRV record for host ","messagePattern":"Unable to look up SRV record for host ","errorType":"exception","errorClass":"MongoConfigurationException","httpStatus":null,"severity":"error","filePath":"extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/dns/MongoDnsClient.java","lineNumber":155,"sourceCode":"                        .await().atMost(timeout);\n            }\n\n            if (srvRecords.isEmpty()) {\n                throw new MongoConfigurationException(\"No SRV records available for host \" + srvHost);\n            }\n            List<String> results = new ArrayList<>();\n            for (SrvRecord srvRecord : srvRecords) {\n                String resolvedHost = srvRecord.target().endsWith(\".\")\n                        ? srvRecord.target().substring(0, srvRecord.target().length() - 1)\n                        : srvRecord.target();\n\n                var r = format(\"%d %d %d %s\", srvRecord.priority(), srvRecord.weight(), srvRecord.port(), resolvedHost);\n                results.add(r);\n            }\n            hosts.addAll(results);\n            log.debugf(\"Resolved SRV records for %s: %s\", srvHost, results);\n        } catch (Throwable e) {\n            throw new MongoConfigurationException(\"Unable to look up SRV record for host \" + srvHost, e);\n        }\n\n        return hosts;\n    }\n\n    /*\n     * A TXT record is just a string\n     * We require each to be one or more query parameters for a MongoDB connection string.\n     * Here we concatenate TXT records together with a '&' separator as required by connection strings\n     */\n    public List<String> resolveTxtRequest(final String host) {\n        if (TXT_CACHE.containsKey(host)) {\n            return TXT_CACHE.get(host);\n        }\n        try {\n            Duration timeout = mongoConfig.dnsLookupTimeout();\n            return Uni.createFrom().<List<String>> deferred(\n                    new Supplier<>() {","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/dns/MongoDnsClient.java#L137-L173","documentation":"The SRV resolution path wraps the entire Vert.x DNS lookup and record-parsing sequence in a catch-all; any failure (DNS timeout, resolver error, malformed records) is converted into MongoConfigurationException(\"Unable to look up SRV record for host ...\", cause).","triggerScenarios":"resolveSrvRequest fails during the Vert.x resolver call `.await().atMost(timeout)` — e.g. DNS server unreachable, query timeout, or a Throwable thrown while parsing records.","commonSituations":"Corporate firewall blocking port 53; DNS timeouts under load (atMost timeout exceeded); misconfigured resolver in Kubernetes pods; transient network outages at startup when the Mongo client is first built.","solutions":["Read the wrapped cause `e` to distinguish timeout vs. NXDOMAIN vs. resolver failure","Fix container DNS configuration (resolv.conf, CoreDNS, VPN routes) so the SRV query can complete","Increase resolution timeouts if the network is slow — check quarkus.mongodb dns timeout settings","Retry the connection after the network recovers; if DNS is flaky, use explicit `quarkus.mongodb.hosts` instead of mongodb+srv://"],"exampleFix":"// before\nquarkus.mongodb.connection-string=mongodb+srv://cluster0.abc123.mongodb.net/db\n// after (explicit hosts, no DNS SRV dependency)\nquarkus.mongodb.hosts=shard-0.abc123.mongodb.net:27017,shard-1.abc123.mongodb.net:27017\nquarkus.mongodb.connection-string=mongodb://cluster0-shard-0.abc123.mongodb.net:27017/db","handlingStrategy":"retry","validationCode":"// Probe DNS resolution before startup\ntry {\n    InetAddress.getByName(srvHost);\n} catch (UnknownHostException e) {\n    throw new ConfigurationException(\"Cannot resolve SRV host \" + srvHost + \": fix DNS first\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return mongoClients.create(name);\n} catch (MongoConfigurationException e) {\n    if (e.getCause() instanceof TimeoutException || e.getCause() instanceof DnsException) {\n        return Retries.withMaxRetries(() -> mongoClients.create(name),\n            Map.of(Retries.MAX_RETRIES, 3, Retries.DELAY, 2000));\n    }\n    throw e;\n}","preventionTips":["Harden container DNS (multiple nameservers, sensible timeouts)","Avoid building Mongo clients during the first milliseconds of pod startup while DNS is warming up","Prefer explicit hosts when DNS is known to be flaky"],"tags":["mongodb","dns","network","timeout"],"backgroundTag":"dns-lookup-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}