quarkusio/quarkus · error · MongoConfigurationException

No SRV records available for host

Error message

No SRV records available for host 

What it means

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.

Source

Thrown at extensions/mongodb-client/runtime/src/main/java/io/quarkus/mongodb/runtime/dns/MongoDnsClient.java:141

                srvRecords = Uni.createFrom().<List<SrvRecord>> deferred(
                        new Supplier<>() {
                            @Override
                            public Uni<? extends List<SrvRecord>> get() {
                                return dnsClient.resolveSRV(srvHost);
                            }
                        })
                        .onFailure().retry().withBackOff(Duration.ofSeconds(1)).atMost(3)
                        .invoke(new Consumer<>() {
                            @Override
                            public void accept(List<SrvRecord> srvRecords) {
                                SRV_CACHE.put(srvHost, srvRecords);
                            }
                        })
                        .await().atMost(timeout);
            }

            if (srvRecords.isEmpty()) {
                throw new MongoConfigurationException("No SRV records available for host " + srvHost);
            }
            List<String> results = new ArrayList<>();
            for (SrvRecord srvRecord : srvRecords) {
                String resolvedHost = srvRecord.target().endsWith(".")
                        ? srvRecord.target().substring(0, srvRecord.target().length() - 1)
                        : srvRecord.target();

                var r = format("%d %d %d %s", srvRecord.priority(), srvRecord.weight(), srvRecord.port(), resolvedHost);
                results.add(r);
            }
            hosts.addAll(results);
            log.debugf("Resolved SRV records for %s: %s", srvHost, results);
        } catch (Throwable e) {
            throw new MongoConfigurationException("Unable to look up SRV record for host " + srvHost, e);
        }

        return hosts;
    }

View on GitHub (pinned to e1c734241f)

Solutions

  1. 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`
  2. Check container/corporate DNS resolution — try an external DNS server or fix resolv.conf
  3. If not using Atlas SRV seeds, switch to `quarkus.mongodb.hosts` with explicit host:port entries and `mongodb://`
  4. Confirm the cluster exists and is in the correct region/account

Example fix

// before
quarkus.mongodb.connection-string=mongodb+srv://wrong-host.mongodb.net/db
// after
quarkus.mongodb.connection-string=mongodb+srv://cluster0.abc123.mongodb.net/db
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check SRV records before building the client
Process p = new ProcessBuilder("nslookup", "-type=SRV", "_mongodb._tcp." + srvHost).start();
String out = new String(p.getInputStream().readAllBytes());
if (!out.contains("SRV")) {
    throw new ConfigurationException("No SRV records for " + srvHost + "; check hostname/DNS");
}

Try / catch

try {
    return mongoClients.create(name);
} catch (MongoConfigurationException e) {
    if (e.getMessage().contains("No SRV records")) {
        throw new IllegalStateException("SRV seed hostname wrong or DNS cannot resolve it: " + e.getMessage(), e);
    }
    throw e;
}

Prevention

When it happens

Trigger: resolveSrvRequest(name) queries DNS for `_mongodb._tcp.<host>` SRV records and gets an empty result set.

Common situations: 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.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/38863a1cffba908c. Report an issue: GitHub.