Kafka TimeoutException: Topic not present in metadata after 60000 ms
Codemia Knowledge Hub ·
org.apache.kafka.common.errors.TimeoutException: Topic not present in metadata after 60000 ms means the Kafka client tried to produce, consume or fetch metadata for a topic that the cluster did not recognize within the default 60000 ms (60 second) window. Either the topic was never created, or it has not propagated properly across the cluster.
The message has two parts:
- Topic not present in metadata: the topic is missing from the metadata known to the broker the client connects to.
- After 60000 ms: the broker or cluster did not recognize the topic within the 60-second window.
Causes and how to fix each
- The topic does not exist:
- Cause: The topic has not been created (or the name is misspelled).
- Fix: Create the topic before accessing it, either manually with the Kafka CLI or by enabling automatic topic creation.
- Network issues:
- Cause: Broken or slow connections between the client and the brokers.
- Fix: Check network connectivity, firewall rules and broker settings.
- Broker configuration:
- Cause: A broker misconfiguration prevents it from reading or writing metadata properly.
- Fix: Check the broker's configuration files (for example
server.properties) for incorrect settings.
- Cluster metadata synchronization:
- Cause: Metadata has not been synchronized across all brokers.
- Fix: Look in the broker logs for synchronization issues.
- Client timeout settings:
- Cause: The default metadata fetch timeout may be too low, especially on high-latency networks.
- Fix: Increase the producer's
max.block.ms(default 60000 ms, the value in the error message), which caps how longsend()waits for metadata.
| Issue Component | Cause | Resolution |
| Topic does not exist | Topic not created or misspelled | Pre-create topic or enable auto-creation |
| Network issues | Poor connectivity or firewall rules | Check and rectify connectivity settings |
| Broker configuration | Misconfiguration in broker settings | Verify and correct broker's server.properties |
| Cluster synchronization | Metadata sync delay among brokers | Monitor logs and ensure synchronization is active |
| Client timeout settings | Low default timeout setting | Adjust max.block.ms in producer config |
How the error surfaces in a producer
Here a producer sends records to myTopic. If myTopic does not exist or is not recognized within the metadata waiting period, the send fails with a TimeoutException wrapped in an ExecutionException:
Preventing it
- Monitor and maintain the Kafka cluster regularly.
- Keep network connectivity and configuration correct between clients and brokers.
- Make sure replication and metadata synchronization are working.
Related reading
- org.apache.kafka.common.KafkaException Failed to construct kafka consumer
- org.apache.kafka.common.KafkaException io.confluent.kafka.serializers.KafkaAvroSerializer
- org.apache.kafka.common.network.InvalidReceiveException Invalid receive (size = 30662099 larger than 30662028)
- org.apache.kafka.connect.errors.ConnectException An exception occurred in the change event producer. This connector will be stopped
- org.apache.spark.SparkException Task not serializable
- org.apache.spark.sql.AnalysisException Can't extract value from probability
- org.springframework.context.ApplicationContextException Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry
- OS X and rabbitMQ ERROR epmd error for host xxx address (cannot connect to host/port)
System design interview problems on this topic
- Design a Distributed Messaging System: solution and walkthrough
- Design a Log Collection and Analysis System: solution and walkthrough
- Design an Ad Click Aggregation System: solution and walkthrough
- Design a Webhook Notification Service: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.