quarkusio/quarkus · error · MongoConfigurationException
Unable to look up TXT record for host
Error message
Unable to look up TXT record for host
What it means
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.
Source
Thrown at extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/dns/MongoDnsClient.java:189
Duration timeout = mongoConfig.dnsLookupTimeout();
return Uni.createFrom().<List<String>> deferred(
new Supplier<>() {
@Override
public Uni<? extends List<String>> get() {
return dnsClient.resolveTXT(host);
}
})
.onFailure().retry().withBackOff(Duration.ofSeconds(1)).atMost(3)
.invoke(new Consumer<>() {
@Override
public void accept(List<String> strings) {
log.debugf("Resolved TXT records for %s: %s", host, strings);
TXT_CACHE.put(host, strings);
}
})
.await().atMost(timeout);
} catch (Throwable e) {
throw new MongoConfigurationException("Unable to look up TXT record for host " + host, e);
}
}
}
View on GitHub (pinned to e1c734241f)
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
Example fix
// before (relies on TXT discovery in a DNS-restricted network) quarkus.mongodb.connection-string=mongodb+srv://cluster0.abc123.mongodb.net/db // after (explicit options) quarkus.mongodb.connection-string=mongodb+srv://cluster0.abc123.mongodb.net/db?ssl=true&replicaSet=rs0 quarkus.mongodb.hosts=shard-0.abc123.mongodb.net:27017
Defensive patterns
Strategy: retry
Validate before calling
// Verify TXT records resolvable before building client
try {
javax.naming.directory.DirContext ctx = new javax.naming.InitialDirContext();
javax.naming.directory.Attributes attrs = ctx.getAttributes("dns:/" + srvHost,
new String[]{"TXT"});
if (attrs.get("TXT") == null) {
log.warn("No TXT records for " + srvHost + "; specify connection options explicitly");
}
} catch (Exception e) {
throw new ConfigurationException("TXT lookup for " + srvHost + " failed: " + e.getMessage(), e);
} Try / catch
try {
return mongoClients.create(name);
} catch (MongoConfigurationException e) {
if (e.getMessage().contains("TXT record")) {
// fall back to explicit options instead of TXT discovery
throw new IllegalStateException("Specify ssl/replicaSet options explicitly; TXT lookup failed", e);
}
throw e;
} Prevention
- 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
When it happens
Trigger: resolveTxtRequest(host) calls the Vert.x resolver for the host's TXT records and the lookup throws or exceeds the `.atMost(timeout)` deadline.
Common situations: 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.
Related errors
- No SRV records available for host
- Unable to look up SRV record for host
- Unable to resolve "${value}"
- Unknown DNS record type:
- Failed to parse CIDR address "${value}"
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/bf380c8079999137.
Report an issue: GitHub.