{"record":{"id":"11801f442cdc6342","repo":"apache/kafka","slug":"there-are-no-nodes-in-the-kafka-cluster","errorCode":null,"errorMessage":"There are no nodes in the Kafka cluster","messagePattern":"There are no nodes in the Kafka cluster","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"clients/src/main/java/org/apache/kafka/clients/NetworkClient.java","lineNumber":910,"sourceCode":"        } else if (foundCanConnect != null) {\n            log.trace(\"Found least loaded node {} with no active connection\", foundCanConnect);\n            return new LeastLoadedNode(foundCanConnect, atLeastOneConnectionReady);\n        } else {\n            log.trace(\"Least loaded node selection failed to find an available node\");\n            return new LeastLoadedNode(null, atLeastOneConnectionReady);\n        }\n    }\n\n    /**\n     * Handle the case when there are no nodes available.\n     * <p>\n     * If bootstrap is disabled or already complete, throw IllegalStateException.\n     * If bootstrap is enabled but not yet complete, return an empty {@link LeastLoadedNode}\n     * so that the caller can continue polling while DNS resolution finishes.\n     */\n    private LeastLoadedNode handleEmptyNodeList() {\n        if (bootstrapConfiguration == BootstrapConfiguration.DISABLED || metadataUpdater.isBootstrapped()) {\n            throw new IllegalStateException(\"There are no nodes in the Kafka cluster\");\n        }\n\n        log.debug(\"No nodes available yet, still in bootstrap phase\");\n        return new LeastLoadedNode(null, false);\n    }\n\n    public static AbstractResponse parseResponse(ByteBuffer responseBuffer, RequestHeader requestHeader) {\n        try {\n            return AbstractResponse.parseResponse(responseBuffer, requestHeader);\n        } catch (BufferUnderflowException e) {\n            throw new SchemaException(\"Buffer underflow while parsing response for request with header \" + requestHeader, e);\n        } catch (CorrelationIdMismatchException e) {\n            if (SaslClientAuthenticator.isReserved(requestHeader.correlationId())\n                && !SaslClientAuthenticator.isReserved(e.responseCorrelationId()))\n                throw new SchemaException(\"The response is unrelated to Sasl request since its correlation id is \"\n                    + e.responseCorrelationId() + \" and the reserved range for Sasl request is [ \"\n                    + SaslClientAuthenticator.MIN_RESERVED_CORRELATION_ID + \",\"\n                    + SaslClientAuthenticator.MAX_RESERVED_CORRELATION_ID + \"]\");","sourceCodeStart":892,"sourceCodeEnd":928,"githubUrl":"https://github.com/apache/kafka/blob/996fb4585aa1bcc8980b0e1b8d6b168b986cd979/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java#L892-L928","documentation":"Thrown by NetworkClient.handleEmptyNodeList() when the cluster metadata contains zero nodes and either bootstrap is disabled or bootstrapping is already complete. It signals the client cannot find any broker to talk to and is not still in the initial DNS-resolution phase where an empty result would be tolerable.","triggerScenarios":"leastLoadedNode() is called when metadataUpdater reports no nodes AND (bootstrap config is DISABLED OR metadataUpdater.isBootstrapped() returns true). Typical when all brokers are removed from metadata or the initial bootstrap list resolved to nothing.","commonSituations":"All bootstrap servers are unreachable/wrong (DNS resolves to empty), broker cluster metadata is empty or corrupt, or the client connected but received no node information. Also happens if all nodes are in long backoff and metadata has been pruned.","solutions":["Verify bootstrap.servers config points to valid, reachable broker addresses.","Check network connectivity and DNS resolution for each bootstrap host.","Ensure the Kafka cluster has live brokers and the client can reach at least one.","If using a custom bootstrap configuration, confirm it is not prematurely marked as bootstrapped."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before relying on leastLoadedNode, ensure metadata has nodes\nif (metadata.fetch().nodes().isEmpty()) {\n    throw new IllegalStateException(\"No nodes available; check bootstrap.servers\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    client.leastLoadedNode(now);\n} catch (IllegalStateException e) {\n    // bootstrap/config issue: surface to operator, do not retry blindly\n}","preventionTips":["Validate bootstrap.servers at startup with a connectivity probe.","Monitor metadata node count; alert when it drops to zero.","Ensure DNS for bootstrap hosts resolves to live brokers."],"tags":["network","metadata","config","bootstrap"],"backgroundTag":null,"analyzedSha":"996fb4585aa1bcc8980b0e1b8d6b168b986cd979","analyzedAt":"2026-08-11T22:03:28.655Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}