org.apache.kafka.common.config.ConfigException Missing required configuration bootstrap.servers which has no default value
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Kafka is a robust, scalable, and effective distributed event streaming platform capable of handling trillions of events a day. While Kafka's capabilities in real-time data processing and high-throughput activities make it indispensable for many applications, setting it up correctly can be crucial. One common issue that users encounter while configuring Kafka producers or consumers is the org.apache.kafka.common.config.ConfigException. This exception includes various subtypes; one particularly prevalent subtype happens due to missing the bootstrap.servers configuration, which notably does not have a default value in Kafka.
Understanding the bootstrap.servers Configuration
The bootstrap.servers configuration specifies a list of host and port pairs that are used by the Kafka client to initially establish connection to the Kafka cluster. This configuration is critical as it serves as the entry point for the Kafka client to perform all operations such as producing and consuming messages, retrieving metadata, and more. This list doesn’t need to include all the brokers in the Kafka cluster. It just needs enough brokers to initially connect to the cluster, which can subsequently use the returned metadata to discover all brokers.
Why It Is Required
This configuration is necessary because Kafka clients need to know where to connect to start interacting with the cluster. Without this information, the client is simply blind and cannot function.
Example of Configuration Usage
Here's how you might typically specify the bootstrap.servers in a Kafka producer configuration in Java:
In this example, the Kafka producer is configured with two bootstrap servers. Even if one of these servers is down, the producer can connect to the other and start interacting with the cluster.
Common Misconfigurations and Troubleshooting
- Omission: Omitting the
bootstrap.serverswill result in theConfigException. - Typographical Errors: Errors in the hostname or port, such as typographical mistakes or incorrect port assignments.
- Network Issues: Even if
bootstrap.serversis correctly configured, network issues can prevent the Kafka client from connecting to these servers.
Troubleshooting Steps
- Check the Configuration: Ensure that the
bootstrap.serversis correctly specified without typographical errors. - Validate Network Connectivity: Make sure that the client machine can connect to the specified hosts and ports over the network.
- Look for Server Logs: Server-side logs might reveal issues related to client connection attempts.
Summary Table
| Issue | Description | Impact | Resolution Steps |
Missing bootstrap.servers | No list of initial Kafka brokers. | Failure to connect to Kafka. | Specify correct server addresses in the configuration. |
| Typographical Errors | Errors in server address or port. | Invalid server connection info. | Verify correctness of bootstrap.servers values. |
| Network Issues | Network connectivity problems. | Inability to reach servers. | Check network connections and firewall settings. |
Conclusion
The bootstrap.servers configuration plays a fundamental role in setting up Kafka clients. Proper configuration ensures seamless connectivity and functionality of the Kafka client applications. By adequately managing this aspect alongside regular checks and balances for network and typographical errors, organizations can harness the full potential of Kafka effectively and efficiently.
Related reading
- org.apache.kafka.common.errors.TimeoutException Topic not present in metadata after 60000 ms
- 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.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 Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.