{"record":{"id":"38863a1cffba908c","repo":"quarkusio/quarkus","slug":"no-srv-records-available-for-host","errorCode":null,"errorMessage":"No SRV records available for host ","messagePattern":"No SRV records available 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":141,"sourceCode":"                srvRecords = Uni.createFrom().<List<SrvRecord>> deferred(\n                        new Supplier<>() {\n                            @Override\n                            public Uni<? extends List<SrvRecord>> get() {\n                                return dnsClient.resolveSRV(srvHost);\n                            }\n                        })\n                        .onFailure().retry().withBackOff(Duration.ofSeconds(1)).atMost(3)\n                        .invoke(new Consumer<>() {\n                            @Override\n                            public void accept(List<SrvRecord> srvRecords) {\n                                SRV_CACHE.put(srvHost, srvRecords);\n                            }\n                        })\n                        .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    }","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/dns/MongoDnsClient.java#L123-L159","documentation":"When resolving a mongodb+srv:// seed host, Quarkus performs an SRV lookup and requires at least one SRV record to build the seed list. If the lookup completes but returns no records, it throws MongoConfigurationException with this message.","triggerScenarios":"resolveSrvRequest(name) queries DNS for `_mongodb._tcp.<host>` SRV records and gets an empty result set.","commonSituations":"MongoDB Atlas cluster hostname typo; the SRV host is a plain hostname rather than the Atlas-provided `<cluster>.mongodb.net` SRV name; DNS resolver in the container/network cannot see the record (split-horizon DNS, blocked UDP/TCP 53); using SRV seeds against non-Atlas self-hosted MongoDB without SRV records.","solutions":["Verify the hostname is the full mongodb+srv seed (e.g. cluster0.xxxxx.mongodb.net) and DNS actually publishes _mongodb._tcp SRV records: `nslookup -type=SRV _mongodb._tcp.cluster0.xxxxx.mongodb.net`","Check container/corporate DNS resolution — try an external DNS server or fix resolv.conf","If not using Atlas SRV seeds, switch to `quarkus.mongodb.hosts` with explicit host:port entries and `mongodb://`","Confirm the cluster exists and is in the correct region/account"],"exampleFix":"// before\nquarkus.mongodb.connection-string=mongodb+srv://wrong-host.mongodb.net/db\n// after\nquarkus.mongodb.connection-string=mongodb+srv://cluster0.abc123.mongodb.net/db","handlingStrategy":"validation","validationCode":"// Pre-check SRV records before building the client\nProcess p = new ProcessBuilder(\"nslookup\", \"-type=SRV\", \"_mongodb._tcp.\" + srvHost).start();\nString out = new String(p.getInputStream().readAllBytes());\nif (!out.contains(\"SRV\")) {\n    throw new ConfigurationException(\"No SRV records for \" + srvHost + \"; check hostname/DNS\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return mongoClients.create(name);\n} catch (MongoConfigurationException e) {\n    if (e.getMessage().contains(\"No SRV records\")) {\n        throw new IllegalStateException(\"SRV seed hostname wrong or DNS cannot resolve it: \" + e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Verify the Atlas SRV hostname with nslookup/dig before deploying","Confirm the container's DNS can resolve external SRV records","Use explicit hosts for non-Atlas or self-hosted MongoDB"],"tags":["mongodb","dns","srv","network"],"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"}