Kafka Exception BrokerNotFoundException
org.apache.kafka.streams.errors.BrokerNotFoundException
Non-retriable
Streams
Indicates that none of the specified BOOTSTRAP_SERVERS_CONFIG brokers could be found.
Common Causes
- `bootstrap.servers` points at a host/port that resolves but has no broker listening (typo, wrong port, stale address after a cluster move), so Streams' admin probe at startup finds zero reachable brokers.
- Advertised listeners mismatch: the broker advertises a hostname (e.g. `localhost` or an internal Docker/K8s name) that the Streams client cannot resolve or route to, so the initial metadata connect succeeds but follow-up broker discovery fails.
- Network/DNS/firewall isolation of a single node: in a multi-instance deployment one host can't reach the brokers (bad DNS, security group, NAT) while the rest start fine.
- Brokers are simply down / not yet up when the Streams app starts (startup ordering race in compose/orchestrators).
Solutions
- Verify connectivity from the failing host with the broker API probe: `kafka-broker-api-versions.sh --bootstrap-server <host:9092>` — if this hangs/fails, it's network/listeners, not Streams.
- Fix `advertised.listeners` on the brokers so they advertise an address reachable by clients (not `localhost` for remote clients); align listener/security-protocol maps.
- Double-check `bootstrap.servers` in the Streams config (real hostnames/IPs, correct port); for containers use the service DNS name, not localhost.
- On a single failing instance in a healthy cluster, debug that host's DNS/firewall/routing specifically (ping/telnet/nc the brokers); and on old clients (<2.7) where an unreachable first bootstrap entry could stall, upgrade and tune `socket.connection.setup.timeout.ms`.
Example Stack Trace
Exception in thread "main" org.apache.kafka.streams.errors.BrokerNotFoundException: Could not find any available broker.
at org.apache.kafka.streams.processor.internals.StreamsKafkaClient.ensureOneNodeIsReady(StreamsKafkaClient.java:204)
at org.apache.kafka.streams.processor.internals.StreamsKafkaClient.getBrokerCompatibility(StreamsKafkaClient.java:281)
at org.apache.kafka.streams.KafkaStreams.checkBrokerVersionCompatibility(KafkaStreams.java:401)
at org.apache.kafka.streams.KafkaStreams.<init>(KafkaStreams.java:622)
at org.apache.kafka.streams.KafkaStreams.<init>(KafkaStreams.java:577)Diagnostic Commands
kafka-broker-api-versions.sh --bootstrap-server localhost:9092 # confirm a broker actually answers from this host
nc -zv broker1 9092 # raw TCP reachability from the failing instance
getent hosts broker1 # confirm DNS resolves the advertised hostname on this nodeRelated
Related Streams exceptions: InternalTopicsAlreadySetupException · InvalidStateStoreException · InvalidStateStorePartitionException · LockException · MisconfiguredInternalTopicException · MissingInternalTopicsException · MissingSourceTopicException · ProcessorStateException
Hitting
BrokerNotFoundException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.