java messaging_error ai_generated true

org.apache.kafka.common.errors.TimeoutException: Failed to update metadata

ID: java/kafka-timeout

Also available as: JSON · Markdown
82%Fix Rate
86%Confidence
75Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
17 active

Root Cause

The Kafka client cannot connect to the broker or fails to complete an operation within the configured timeout. Usually caused by incorrect bootstrap server addresses, network connectivity issues, or broker overload.

generic

Workarounds

  1. 88% success Verify bootstrap.servers configuration points to reachable broker addresses and test connectivity
    1. Check bootstrap.servers in your Kafka client config — ensure it contains the correct broker host:port. 2. Test TCP connectivity: 'nc -zv broker-host 9092' or 'telnet broker-host 9092'. 3. If using Docker/Kubernetes, ensure the advertised.listeners on the broker matches what clients use. 4. Check for DNS resolution issues: 'nslookup broker-host'. 5. Verify no firewall or security group blocks port 9092.
  2. 82% success Check broker health and ensure topics are properly created with sufficient partitions
    1. Verify broker is running: check broker logs for errors. 2. Ensure the topic exists: 'kafka-topics.sh --list --bootstrap-server broker:9092'. 3. If auto.create.topics.enable is false, create the topic manually. 4. Check broker resource usage (disk, memory, CPU). 5. If producing, verify acks and retries settings. Set retries to a positive number and delivery.timeout.ms appropriately.

Dead Ends

Common approaches that don't work:

  1. Increasing request.timeout.ms to very large values to avoid the timeout 75% fail

    If the broker is unreachable due to a network or configuration issue, waiting longer will not help. Large timeouts just delay error detection and cause the application to hang rather than fail fast.

  2. Restarting the Kafka client application without checking broker connectivity 80% fail

    If the root cause is a misconfigured bootstrap.servers, DNS issue, or firewall rule, restarting the client will reproduce the same timeout. The connectivity issue must be resolved first.

Error Chain

Leads to:
Preceded by:
Frequently confused with: