apache/kafka · critical · KafkaException

Failed to create new KafkaAdminClient

Error message

Failed to create new KafkaAdminClient

What it means

A KafkaException thrown by KafkaAdminClient.createInternal wrapping any Throwable raised while building the Metrics, NetworkClient, and the KafkaAdminClient instance. It is a fatal 'the client never came up' error: the partially-built Metrics and NetworkClient are closed before re-throwing.

Solutions

  1. Inspect exception.getCause() to find the real failure (often a ConfigException, IOException, or NoClassDefFoundError).
  2. Fix the underlying cause: correct security config, remove/fix the broken MetricsReporter, resolve classpath.
  3. If the cause is transient (DNS, temp network), retry Admin.create once it is resolved.

Example fix

// before
Admin admin = Admin.create(props); // throws KafkaException

// after
try {
    admin = Admin.create(props);
} catch (KafkaException e) {
    log.error("Admin create failed: {}", e.getCause());
    throw e;
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    this.admin = Admin.create(props);
} catch (KafkaException e) {
    Throwable cause = e.getCause();
    log.error("Admin creation failed; cause: {}", cause == null ? "unknown" : cause.toString());
    throw e;
}

Prevention

When it happens

Trigger: Any failure during the production createInternal path: invalid config that passed type checks but failed at runtime, Metrics construction failure, NetworkClient construction failure, ClientTelemetryReporter setup error, or an OutOfMemoryError. The original cause is chained as the exception's cause.

Common situations: Misconfigured security (SASL/SSL) that throws during channel setup; a MetricsReporter plugin that throws in its constructor; missing or incompatible client-telemetry setup; classpath issues where a required class is absent.

Related errors


AI-assisted analysis of apache/kafka@996fb4585a (2026-08-11). Data as JSON: /api/errors/0cfeac24f3477d33. Report an issue: GitHub.

Appendix: source

Thrown at clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java:626

                clientId,
                metrics,
                "admin-client",
                logContext,
                apiVersions,
                time,
                1,
                (int) TimeUnit.HOURS.toMillis(1),
                null,
                metadataManager.updater(),
                (hostResolver == null) ? new DefaultHostResolver() : hostResolver,
                null,
                clientTelemetryReporter.map(ClientTelemetryReporter::telemetrySender).orElse(null));
            return new KafkaAdminClient(config, clientId, time, metadataManager, metrics, networkClient,
                timeoutProcessorFactory, logContext, clientTelemetryReporter);
        } catch (Throwable exc) {
            closeQuietly(metrics, "Metrics");
            closeQuietly(networkClient, "NetworkClient");
            throw new KafkaException("Failed to create new KafkaAdminClient", exc);
        }
    }

    // Visible for tests
    static KafkaAdminClient createInternal(AdminClientConfig config,
                                           AdminMetadataManager metadataManager,
                                           KafkaClient client,
                                           Time time) {
        Metrics metrics = null;
        String clientId = generateClientId(config);
        List<MetricsReporter> reporters = CommonClientConfigs.metricsReporters(clientId, config);
        Optional<ClientTelemetryReporter> clientTelemetryReporter = CommonClientConfigs.telemetryReporter(clientId, config);
        clientTelemetryReporter.ifPresent(reporters::add);

        try {
            metrics = new Metrics(new MetricConfig(), reporters, time);
            LogContext logContext = createLogContext(clientId);
            return new KafkaAdminClient(config, clientId, time, metadataManager, metrics,

View on GitHub (pinned to 996fb4585a)