{"record":{"id":"bf380c8079999137","repo":"quarkusio/quarkus","slug":"unable-to-look-up-txt-record-for-host","errorCode":null,"errorMessage":"Unable to look up TXT record for host ","messagePattern":"Unable to look up TXT 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":189,"sourceCode":"            Duration timeout = mongoConfig.dnsLookupTimeout();\n            return Uni.createFrom().<List<String>> deferred(\n                    new Supplier<>() {\n                        @Override\n                        public Uni<? extends List<String>> get() {\n                            return dnsClient.resolveTXT(host);\n                        }\n                    })\n                    .onFailure().retry().withBackOff(Duration.ofSeconds(1)).atMost(3)\n                    .invoke(new Consumer<>() {\n                        @Override\n                        public void accept(List<String> strings) {\n                            log.debugf(\"Resolved TXT records for %s: %s\", host, strings);\n                            TXT_CACHE.put(host, strings);\n                        }\n                    })\n                    .await().atMost(timeout);\n        } catch (Throwable e) {\n            throw new MongoConfigurationException(\"Unable to look up TXT record for host \" + host, e);\n        }\n    }\n}\n","sourceCodeStart":171,"sourceCodeEnd":193,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/dns/MongoDnsClient.java#L171-L193","documentation":"Alongside SRV records, mongodb+srv:// discovery fetches TXT records for connection options. resolveTxtRequest wraps the Vert.x TXT lookup in a catch-all and converts any failure (timeout, resolver error) into MongoConfigurationException with this message.","triggerScenarios":"resolveTxtRequest(host) calls the Vert.x resolver for the host's TXT records and the lookup throws or exceeds the `.atMost(timeout)` deadline.","commonSituations":"Same DNS infrastructure problems as SRV lookups (blocked port 53, pod DNS misconfig); Atlas TXT records unreachable due to split-horizon DNS; transient resolver failures during application startup.","solutions":["Inspect the wrapped cause to identify timeout vs. resolver refusal","Repair DNS resolution in the deployment environment (check /etc/resolv.conf, CoreDNS, VPN)","Run `nslookup -type=TXT <host>` from the same network to reproduce and verify","If DNS is unreliable, specify all options explicitly in the connection string/hosts so TXT discovery isn't needed"],"exampleFix":"// before (relies on TXT discovery in a DNS-restricted network)\nquarkus.mongodb.connection-string=mongodb+srv://cluster0.abc123.mongodb.net/db\n// after (explicit options)\nquarkus.mongodb.connection-string=mongodb+srv://cluster0.abc123.mongodb.net/db?ssl=true&replicaSet=rs0\nquarkus.mongodb.hosts=shard-0.abc123.mongodb.net:27017","handlingStrategy":"retry","validationCode":"// Verify TXT records resolvable before building client\ntry {\n    javax.naming.directory.DirContext ctx = new javax.naming.InitialDirContext();\n    javax.naming.directory.Attributes attrs = ctx.getAttributes(\"dns:/\" + srvHost,\n        new String[]{\"TXT\"});\n    if (attrs.get(\"TXT\") == null) {\n        log.warn(\"No TXT records for \" + srvHost + \"; specify connection options explicitly\");\n    }\n} catch (Exception e) {\n    throw new ConfigurationException(\"TXT lookup for \" + srvHost + \" failed: \" + e.getMessage(), e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return mongoClients.create(name);\n} catch (MongoConfigurationException e) {\n    if (e.getMessage().contains(\"TXT record\")) {\n        // fall back to explicit options instead of TXT discovery\n        throw new IllegalStateException(\"Specify ssl/replicaSet options explicitly; TXT lookup failed\", e);\n    }\n    throw e;\n}","preventionTips":["Encode all options (ssl, replicaSet, authSource) in the connection string so TXT discovery is best-effort","Ensure the environment DNS can resolve external TXT records","Monitor DNS resolver health in Kubernetes clusters"],"tags":["mongodb","dns","txt","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"}