> ## Content Index
> Fetch the complete content index at: https://www.ggorantala.dev/llms.txt
> Use this file to discover other available public pages before exploring further.

# Kafka 'Topic Not Present in Metadata After 60000 ms', Fixed
- URL: https://www.ggorantala.dev/kafka-topic-not-present-in-metadata/
- Published: 2026-12-03T06:42:10.000Z
- Updated: 2026-12-03T06:42:10.000Z
- Description: Your producer blocked for a full minute, then failed with 'Topic not present in metadata after 60000 ms'. Kafka never named your topic. Here's how to tell a missing topic from a typo, an unreachable broker or a bad partition number, and fix the right one.
- Author: Gopi Gorantala
- Tags: topic-not-in-metadata, max-block-ms, auto-create-topics, kafka-producer, kafka-connections, kafka, kafka-errors

```java
producer.send(new ProducerRecord<>("ledger-posting", postingId, payload)).get();

```

Put that line in a ledger-posting job and nobody notices it's wrong for as long as the dev broker auto-creates topics. The real topic is `ledger-postings`, plural. Point the job at a cluster with auto-create switched off and every send hangs for exactly one minute, then dies with this:

```log
java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.TimeoutException: Topic ledger-posting not present in metadata after 60000 ms.
    ...
Caused by: org.apache.kafka.common.errors.TimeoutException: Topic ledger-posting not present in metadata after 60000 ms.
Caused by: org.apache.kafka.common.errors.UnknownTopicOrPartitionException: This server does not host this topic-partition.

```

(Client 4.4.0\. The message text and the cause chain are what `KafkaProducer` builds at the 4.4.0 tag; stack frames left out.)

"Topic not present in metadata after 60000 ms" is the Kafka producer telling you it asked the cluster about your topic, kept asking for `max.block.ms`, and never got an answer that included it. It doesn't say why, which is why the top answers online split between "create the topic" and "raise the timeout". Only one of those is ever right.

You'll see it on the first `send()` to a topic, usually right after startup or a deploy, and almost never in the middle of a healthy run. That timing alone is a clue.

There are older and newer wordings. Clients up to 2.1 said `Failed to update metadata after 60000 ms.` with no topic name at all. From 2.2 the message names the topic. And from 3.9 the client attaches whatever error the broker last reported for that topic as the cause, which is the single most useful change this error has ever had. If your stack trace has no `Caused by` under the timeout, you're on an older client or the broker never answered at all. Both of those tell you something.

There's a partition-flavoured sibling too:

```log
org.apache.kafka.common.errors.TimeoutException: Partition 7 of topic ledger-postings with partition count 6 is not present in metadata after 60000 ms.

```

Same mechanism, different mistake. More on it below.

## How far did the client get?

Everyone's first instinct, mine included, is network. A timeout is a timeout, right? So `max.block.ms` goes to two minutes, and you wait two minutes for the same failure. That's the trap: the word "timeout" makes you look at the clock, and the clock is never the problem here.

The question that actually matters is how far the client got before it gave up. There are four places it can stall, and the producer's own WARN lines tell you which one, if you read the log above the exception instead of the exception itself:

| What's in the log before the timeout                                      | How far the client got                                                   | Where to look                                  |
| ------------------------------------------------------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------- |
| Connection to node -1 (...) could not be established                      | Never reached the bootstrap server                                       | wrong host or port, broker down                |
| Connection to node 1 (...) could not be established                       | Reached bootstrap, can't reach the address the broker advertised         | advertised.listeners                           |
| ... correlation id N : {ledger-posting=UNKNOWN\_TOPIC\_OR\_PARTITION}     | Talking to the cluster fine; topic doesn't exist and isn't being created | topic name, auto-create, the cluster you're on |
| ... correlation id N : {ledger-postings=LEADER\_NOT\_AVAILABLE} repeating | Topic exists or is being created, has no leader                          | broker log, replication factor                 |

Wordings drift. Before 3.9 the metadata WARN reads `Error while fetching metadata with correlation id N : {...}`; from 3.9 it's `The metadata response from the cluster reported a recoverable issue with correlation id N : {...}`. Since 3.7 the connection line ends "Node may not be available." instead of "Broker may not be available." Grep for both across services on mixed client versions.

Then, from any machine that can reach the cluster, check what the cluster actually knows:

```bash
kafka-topics.sh --bootstrap-server broker-1:9092 --command-config client.properties --list | grep -i ledger
kafka-topics.sh --bootstrap-server broker-1:9092 --command-config client.properties --describe --topic ledger-postings
kcat -b broker-1:9092 -L -t ledger-posting     # metadata as a client sees it, including the advertised broker addresses

```

`--command-config` is only needed on a secured cluster. `--list` needs `Describe` on the topics you want to see, so an empty list with a restricted user doesn't prove the topic is missing. If the first two node lines in the table are what you see, stop here: this is a connection problem wearing a metadata costume, and [the connection-to-node post](https://ggorantala.dev/kafka-connection-to-node-1-broker-may-not-be-available/?ref=ggorantala.dev) and [the advertised listeners explainer](https://ggorantala.dev/kafka-advertised-listeners-explained/?ref=ggorantala.dev) are where you want to be. The [connection errors comparison](https://ggorantala.dev/kafka-connection-errors-compared/?ref=ggorantala.dev) lays out all of them side by side.

## Reproduce it on a throwaway broker

A one-broker KRaft cluster with auto-create turned off reproduces the common case and the partition case. Run it on your laptop, never on a shared cluster.

One honest note before you start: the session I wrote this in had no Docker daemon and no route to Maven Central, so I couldn't run this lab end to end here. The steps below are built from the `apache/kafka` image docs and the producer source at 4.4.0; the expected output is what that source prints, not a paste from my terminal.

**What you need:** Docker, a JDK 17 or newer, and the Kafka 4.4.0 binary download (`kafka_2.13-4.4.0.tgz`) unpacked somewhere. Its `libs/` folder has `kafka-clients-4.4.0.jar` and the SLF4J jars, and its `bin/` has the CLI tools.

**The broker.** The `apache/kafka` image ignores its built-in defaults as soon as you pass any `KAFKA_` variable, so the file sets everything a single KRaft node needs:

```yaml
services:
  kafka:
    image: apache/kafka:4.4.0
    ports:
      - "9092:9092"
    environment:
      KAFKA_NODE_ID: 1
      KAFKA_PROCESS_ROLES: broker,controller
      KAFKA_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
      KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
      KAFKA_CONTROLLER_QUORUM_VOTERS: 1@localhost:9093
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
      KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: "false"   # what most production clusters and MSK do

```

**The producer.** One file, run with the libs from the download on the classpath:

```java
import org.apache.kafka.clients.producer.*;
import org.apache.kafka.common.serialization.StringSerializer;
import java.util.Properties;

public class Lab {
    public static void main(String[] args) throws Exception {
        Properties p = new Properties();
        p.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
        p.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        p.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
        p.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, "5000"); // lab only: fail in 5 s instead of 60
        String topic = args[0];
        Integer partition = args.length > 1 ? Integer.valueOf(args[1]) : null;
        try (Producer<String, String> producer = new KafkaProducer<>(p)) {
            producer.send(new ProducerRecord<>(topic, partition, "posting-41312", "{\"amount\":118.40}")).get();
            System.out.println("sent");
        }
    }
}

```

Steps:

1. `docker compose up -d`, then wait until `docker compose logs kafka` shows the broker has started.
2. Create the real topic with six partitions: `bash ~/kafka_2.13-4.4.0/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic ledger-postings --partitions 6 --replication-factor 1`
3. Send to the typo. Expected: about five seconds of nothing, then `Topic ledger-posting not present in metadata after 5000 ms.` with `UnknownTopicOrPartitionException` as the cause: `bash java -cp "$HOME/kafka_2.13-4.4.0/libs/*" Lab.java ledger-posting`
4. Send to the right topic, wrong partition. Expected: `Partition 7 of topic ledger-postings with partition count 6 is not present in metadata after 5000 ms.` `bash java -cp "$HOME/kafka_2.13-4.4.0/libs/*" Lab.java ledger-postings 7`
5. Send to the right topic, no partition. Expected: `sent`.
6. `docker compose stop kafka` and repeat step 5\. Now the log fills with `Connection to node -1` lines and the timeout has no cause underneath it, because no metadata response ever arrived.

**The forcing lever** is `max.block.ms=5000`. Production uses the default, 60000 on 4.4, which is where the "60000 ms" in the message comes from: the number is your `max.block.ms`, not a broker setting.

**Confirmation:** the client's WARN lines go through SLF4J, so you may only see the exception unless you give the run a logging config. Either way, the exception appears from `get()` (or in your callback), never thrown by `send()` itself, and only after the full `max.block.ms` has passed. If you get `TopicAuthorizationException` instead, that's a different problem with [its own post](https://ggorantala.dev/kafka-topicauthorizationexception-not-authorized/?ref=ggorantala.dev).

**Teardown:** `docker compose down -v`. The `-v` deletes the broker's data volume. On a lab that's what you want; on anything else it's the cluster.

## The one-paragraph version

Before the producer can put a record anywhere, it needs to know how many partitions the topic has and which broker leads each one. It gets that from a metadata request. If the cluster's answer keeps leaving your topic out (because the topic doesn't exist, isn't being created, or the client can't reach anyone to ask), the producer waits up to `max.block.ms` on the calling thread and then fails the send with this `TimeoutException`. Nothing was written. Nothing was retried in the background after that.

## Following it into the client

When you call `send()`, `KafkaProducer.doSend()` calls `waitOnMetadata()` before it serializes anything or goes near the record accumulator. That method looks in the cached cluster metadata for the topic. Not there? It marks the topic as wanted (`requestUpdateForTopic`), wakes the network thread, and blocks on `awaitUpdate()` for whatever is left of `max.block.ms`. Each response comes back, the loop checks again, and around it goes until the topic shows up with a partition count, or the clock runs out.

Two details in that loop matter more than the rest.

First, before the loop waits again, it calls `metadata.maybeThrowExceptionForTopic(topic)`. That throws straight away if the last response marked the topic as unauthorized (`TopicAuthorizationException`) or invalid (`InvalidTopicException`). So on a modern client, a missing `Describe` ACL is not hidden behind a 60-second timeout; it comes back fast and with the right name. I expected the opposite, because so many forum threads list ACLs as a cause of this timeout. The source says otherwise for the cases it records. What does still come back as a timeout is anything the client treats as retriable: `UNKNOWN_TOPIC_OR_PARTITION` and `LEADER_NOT_AVAILABLE` are the two you'll meet.

Second, look at how the timeout is built. Up to 3.8 it was `new TimeoutException(message)` and the broker's actual complaint was thrown away. I went through the producer at the 2.1, 2.2, 3.6, 3.7, 3.8 and 3.9 tags to pin this down, and 3.9 is where it changed: the error the cluster last reported for that topic becomes the cause, and the network client's WARN was reworded at the same release. So the very same mistake gives a bare timeout on a 3.8 client and a timeout with `UnknownTopicOrPartitionException` underneath on 3.9\. If you're stuck on an older client, the WARN lines are your only window into that cause.

And a detail that catches people out in a different way: `doSend()` catches `ApiException` (which `TimeoutException` is), calls your callback with it, and returns a failed future. It doesn't throw. So `send()` blocks your thread for a minute and then returns normally. If nobody calls `get()` and the callback doesn't log, the record vanishes and the only trace is a minute of latency on whatever request made the call.

```log
send() called
  └─ waitOnMetadata(topic)
       ├─ topic in cache with enough partitions? ── yes ──> serialize, append to batch, return
       ├─ unauthorized / invalid topic? ───────────────────> fail fast (TopicAuthorization / InvalidTopic)
       └─ no: request metadata, wait, loop
            └─ max.block.ms used up ───────────────────────> TimeoutException (3.9+: last topic error as cause)

```

The partition variant is the same loop with a different exit condition: the topic is there, but the partition you asked for is `>=` the partition count. It comes from hard-coded partition numbers, or a count taken off a different cluster. Adding partitions hides it and breaks key ordering for everything else on the topic, so fix the code that picks the partition.

## Finding the real cause

In a live system, the order I go in:

1. **Read the cause chain.** On 3.9+ clients the `Caused by` names the topic error. `UnknownTopicOrPartitionException` means the cluster doesn't have that topic. No cause at all on a 3.9+ client means no metadata response ever came back: go to the connection checks. The [guide to reading Kafka errors](https://ggorantala.dev/read-kafka-error-message/?ref=ggorantala.dev) covers chains with Spring wrapped around them.
2. **Grep the producer's WARN lines** from the minute before the exception: `could not be established`, `correlation id`. They map straight onto the table in the triage section.
3. **Compare names byte for byte.** Copy the topic name out of the exception and out of `kafka-topics.sh --list` and diff them. Plurals, `-` versus `_` versus `.`, case (topic names are case-sensitive), a trailing space from a property file, an environment prefix like `dev.` that the config template forgot. This one step settles a surprising share of them.
4. **Confirm which cluster you're on.** Print the effective `bootstrap.servers` the client logged at startup (the `ProducerConfig values:` block). A staging app pointing at the dev cluster's DNS name looks exactly like a missing topic.
5. **Check whether the topic should have been auto-created.** `auto.create.topics.enable` is a read-only broker setting, default `true` on 4.4\. Many production clusters turn it off, and Amazon MSK's default configuration ships it `false`. If your dev cluster creates topics on first touch and production doesn't, this error is the first time you find out.
6. **If the WARN shows `LEADER_NOT_AVAILABLE` for the whole minute,** the topic exists or is mid-creation but has no leader. Check `kafka-topics.sh --describe` for `Leader: none`, and the broker log. On small dev clusters a `default.replication.factor` bigger than the number of live brokers stops auto-creation from ever succeeding; see the [replication factor post](https://ggorantala.dev/kafka-invalidreplicationfactorexception-fix/?ref=ggorantala.dev) and the [leader-not-available post](https://ggorantala.dev/kafka-leader-not-available-fix/?ref=ggorantala.dev).

Then the fix, which depends on what you found:

| Cause                                         | Fix                                                                                                          | What it costs                                    |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------ |
| Typo or wrong environment prefix              | Fix the name in config; load topic names from one place                                                      | Nothing                                          |
| Topic doesn't exist, auto-create off          | Create it with the right partitions and replication (CLI, IaC, Strimzi KafkaTopic, or Spring NewTopic beans) | Someone has to own topic creation                |
| Wrong cluster                                 | Fix bootstrap.servers per environment                                                                        | Nothing                                          |
| Unreachable broker or bad advertised listener | Fix the listener or network, not the client                                                                  | A broker restart if advertised.listeners changes |
| Partition number too high                     | Fix the code choosing partitions, or let the partitioner choose                                              | A code change                                    |
| No leader                                     | Fix the broker or the replication factor                                                                     | Depends on why                                   |

For the missing topic, creating it explicitly looks like this (needs `Create` on the cluster or the topic on a secured cluster):

```bash
kafka-topics.sh --bootstrap-server broker-1:9092 --command-config client.properties \
  --create --topic ledger-postings --partitions 6 --replication-factor 3 --config min.insync.replicas=2

```

Or, in a Spring Boot app, declare it and let `KafkaAdmin` create it at startup:

```java
@Bean
NewTopic ledgerPostings() {
    return TopicBuilder.name("ledger-postings").partitions(6).replicas(3)
            .config("min.insync.replicas", "2").build();
}

```

That needs a principal allowed to create topics. On locked-down clusters it isn't, and you'd want topics in code review anyway.

### What isn't a fix

Raising `max.block.ms`. The topic won't appear in minute two if it wasn't coming in minute one. All you get is a longer stall on the calling thread. I'd go the other way on request paths: a `max.block.ms` of a few seconds turns a one-minute hang into a fast, loud failure. It's a producer setting, default 60000 on 4.4; in Spring Boot set it with `spring.kafka.producer.properties.max.block.ms`. Bear in mind it also bounds the transactional calls and `partitionsFor()`, so don't set it below what those need.

Turning on `auto.create.topics.enable` in production. It makes the error go away by creating `ledger-posting` with whatever partition count and replication the broker defaults to (`default.replication.factor` is 1 out of the box). Now you have two topics, half your data in the wrong one, and a consumer reading the right one wondering where the postings went.

### In Spring and Spring Cloud Stream

`KafkaTemplate.send()` still blocks the calling thread for up to `max.block.ms`, because it calls the same `KafkaProducer.send()`. The failure then arrives on the returned `CompletableFuture` as a `KafkaProducerException` ("Failed to send") with this `TimeoutException` as its cause, which is why Spring users often never see the metadata message unless they log the whole chain. [The KafkaProducerException post](https://ggorantala.dev/spring-kafka-kafkaproducerexception-failed-to-send/?ref=ggorantala.dev) goes into reading that future. If your topic names end in `-retry` or `-dlt`, the missing topic is probably a retry topic that `@RetryableTopic` was supposed to create; that has its own article on [retry topic errors](https://ggorantala.dev/spring-kafka-retryabletopic-errors/?ref=ggorantala.dev).

Spring Cloud Stream's Kafka binder creates destination topics itself through the admin client, controlled by `spring.cloud.stream.kafka.binder.autoCreateTopics`. When it's off, or the principal can't create topics, the first send to a binding whose topic doesn't exist produces this same timeout.

## How not to end up here again

The pattern that keeps this error out of my services: topic names live in exactly one config property per topic, topics are created by something other than the producer (Terraform or Strimzi `KafkaTopic` resources, reviewed like code), and every environment, including the laptop, runs with auto-create off.

Sounds fussy. It means a typo fails on your laptop in five seconds instead of on the first production deploy.

The startup check I add to services that produce to fixed topics:

```java
@Bean
ApplicationRunner checkTopics(KafkaAdmin admin, @Value("${ledger.topic}") String topic) {
    return args -> {
        Map<String, TopicDescription> found = admin.describeTopics(topic);   // throws if it doesn't exist
        log.info("Producing to {} with {} partitions", topic, found.get(topic).partitions().size());
    };
}

```

It fails the deploy, not the first customer request. Needs `Describe` on the topic, which the producer needs anyway.

## Catching it before production does

- **Alert on the client metrics, not only the exception.** A producer stuck in metadata waits shows up as a jump in `record-error-rate` and in end-to-end latency on whatever calls `send()`. A single minute-long request is easy to miss in percentiles; the error rate isn't.
- **Run integration tests against a broker with auto-create off.** A Testcontainers Kafka at your production version with `KAFKA_AUTO_CREATE_TOPICS_ENABLE=false` catches the typo in CI. An embedded or default dev broker that creates topics on demand hides it.
- **Diff topic names in CI.** If topics are declared in IaC, a check that every topic name in the service's config exists in the IaC catalogue is ten lines of script.
- **Version notes.** Up to 2.1: `Failed to update metadata after N ms.` From 2.2: the topic is named. From 3.9: the cause is attached and the metadata WARN says "reported a recoverable issue". What usually changes on upgrade is the client, and with it what your log alerts match. Managed services differ mostly in auto-create defaults; re-check those when you migrate.

## The short list

- The number in the message is your `max.block.ms`. The broker didn't time out; your producer gave up waiting for metadata that named the topic.
- Read the WARN lines above the exception. `node -1`, `node 1`, `UNKNOWN_TOPIC_OR_PARTITION` and `LEADER_NOT_AVAILABLE` each point at a different fix.
- On 3.9+ clients, the `Caused by` tells you what the cluster said. No cause means nobody answered.
- Missing `Describe` ACLs come back as `TopicAuthorizationException`, fast, not as this timeout.
- Turn auto-create off everywhere, laptop included, and typos fail in seconds instead of on deploy day.

## Questions people ask about this one

### How do I fix "Topic not present in metadata after 60000 ms" in Kafka?

Find out whether the topic exists on the cluster your client actually connects to: `kafka-topics.sh --list` against the same `bootstrap.servers`, and compare the name exactly. If it doesn't exist and auto-create is off, create it. If it exists, read the producer's WARN lines: connection errors mean a network or `advertised.listeners` problem, and `LEADER_NOT_AVAILABLE` means the topic has no leader.

### Should I increase max.block.ms to fix it?

No. The default is 60000 ms on 4.4, and if the topic hasn't shown up in a minute it won't in two. Raising it only makes the calling thread hang longer; on request paths, a shorter `max.block.ms` is usually the better choice because it fails fast.

### Is "Failed to update metadata after 60000 ms" the same error?

Yes. That's how Kafka clients up to 2.1 worded it, without the topic name. From 2.2 the message names the topic, and from 3.9 it also carries the broker's last error for that topic as the cause.

### Why does send() block for 60 seconds before failing?

Because the producer needs the topic's partitions and leaders before it can queue the record, and it waits for them on your thread, up to `max.block.ms`. After that, `send()` returns a failed future instead of throwing, so the error only appears when you call `get()` or in your callback. If you do neither, it's silently lost.