IllegalStateException: Topic(s) [XYZ] is/are not present and missingTopicsFatal is true

set spring.kafka.listener.missing-topics-fatal=false

on your application.yml or application.properties


Your config is using Zookeeper, not Kafka as the bootstrap servers

Use port 9092, not 2181

Also, that Spotify container is not maintained, so I suggest finding a newer one


This may not be the answer to the question, but I'm putting this so it can be helpful to someone else.

I faced the same exception even when I used the appropriate port number in the config (9092)

Here's the stacktrace.

    java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
....

Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry'; nested exception is java.lang.IllegalStateException: Topic(s) [my-cute-topic] is/are not present and missingTopicsFatal is true

The Solution

I just created the topic in my local kafka and it worked fine.