Kafka Error NOT_CONTROLLER
Error code 41 · Retriable Broker
This is not the correct controller for this cluster.
Common Causes
- Client or broker sent a controller-only request (e.g., LeaderAndIsr, UpdateMetadata) to a broker that is not the current active controller
- Controller failover in progress — old controller is stepping down and new election hasn't completed yet
- Stale metadata cached by the client or broker pointing to the previous controller's broker ID
Solutions
- This is retriable — the client should refresh metadata and retry; ensure retry logic is enabled and backoff is configured (retry.backoff.ms)
- If NOT_CONTROLLER errors persist, check ZooKeeper or KRaft quorum health; a prolonged election indicates a quorum or connectivity issue
- Monitor controller election rate in JMX (kafka.controller:type=KafkaController,name=ActiveControllerCount); repeated elections signal instability
Diagnostic Commands
# Check controller or quorum status
kafka-metadata-quorum.sh --bootstrap-server localhost:9092 describe --status 2>/dev/null || kafka-broker-api-versions.sh --bootstrap-server localhost:9092 | head -5
# Look for controller election events in logs
grep 'NOT_CONTROLLER\|ResignedFrom\|Resigning\|new controller' /var/log/kafka/server.log | tail -20Related APIs
This error can be returned by: AlterConfigs · CreatePartitions · CreateTopics · DeleteTopics · ElectLeaders · UpdateFeatures
Debugging Kafka errors? Conduktor Console gives you real-time visibility into your cluster. Explore all errors in the Error Decoder.