kafka
connection_error
ai_generated
true
org.apache.kafka.common.KafkaException: Failed to construct kafka consumer: Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
ID: kafka/connection-refused-bootstrap
90%Fix Rate
90%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3 | active | — | — | — |
Root Cause
Cannot connect to Kafka bootstrap server. Broker not running, wrong address, firewall blocking, or advertised.listeners misconfigured.
genericWorkarounds
-
92% success Verify broker is running and listening on expected port
ss -tlnp | grep 9092; sudo journalctl -u kafka --tail=50
Sources: https://kafka.apache.org/documentation/#brokerconfigs
-
90% success Check advertised.listeners matches how clients reach the broker
In server.properties: advertised.listeners=PLAINTEXT://actual-hostname:9092 # must be routable from client
-
85% success Test connectivity from client machine
nc -zv broker-host 9092 # or: kafkacat -b broker-host:9092 -L
Dead Ends
Common approaches that don't work:
-
Use the ZooKeeper address as bootstrap server
92% fail
Clients connect to Kafka brokers, not ZooKeeper. ZooKeeper port (2181) is not the broker port (9092).
-
Only check if broker is running and assume network is fine
75% fail
advertised.listeners misconfiguration is the #1 cause in Docker/cloud. Broker runs fine but clients cannot reach the advertised address.