Kafka Exception DisconnectException
org.apache.kafka.common.errors.DisconnectException
Retriable
Client
Server disconnected before a request could be completed.
Common Causes
- The TCP connection to a broker was closed mid-request (broker restart/rolling upgrade, load balancer idle timeout, or connections.max.idle.ms elapsing)
- A network partition or firewall dropped the connection
- The targeted broker was no longer the leader and closed the stale connection
Solutions
- It is retriable — the client transparently reconnects and re-sends; usually no action is needed for transient cases
- If frequent, check connections.max.idle.ms on the broker vs idle periods on the client, and any LB/NAT idle timeouts between them
- During rolling restarts this is expected; ensure retries and request.timeout.ms are sized to ride through a broker bounce
Example Stack Trace
org.apache.kafka.common.errors.DisconnectException: Cancelled request with header RequestHeader(apiKey=METADATA, ...) due to node 2 being disconnectedRelated
Related Client exceptions: InterruptException · LogTruncationException
Hitting
DisconnectException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.