---
title: "TimeoutException in Kafka producers: causes and fixes"
description: "Expiring N record(s), topic not present in metadata, buffer full: which Kafka producer limit is behind a TimeoutException and how to fix the cause."
url: https://monedula.dev/kafka/troubleshooting/producer-timeout-exception/
---

# TimeoutException (REQUEST_TIMED_OUT)

Kafka error · REQUEST_TIMED_OUT · retriable.

Exception: `org.apache.kafka.common.errors.TimeoutException`

## Quick answer

The producer gave up on a record because a time limit ran out: send() could not get topic metadata or buffer space within max.block.ms, or the record was not acknowledged within delivery.timeout.ms ("Expiring N record(s)"). The message says which limit fired; fix what made the brokers slow or unreachable instead of only raising the timeout.

## What it means

org.apache.kafka.common.errors.TimeoutException covers several timers, and the message tells them apart. "Topic orders not present in metadata after 60000 ms." means send() waited max.block.ms (default 60 seconds) for metadata. "Failed to allocate 1024 bytes within the configured max blocking time 60000 ms" comes from BufferExhaustedException, a subclass: buffer.memory (33554432 bytes by default) was full of records waiting to be sent or acknowledged. In both cases send() blocks the calling thread for up to max.block.ms, then returns a failed Future and calls the callback. "Expiring 1 record(s) for orders-0:120001 ms has passed since batch creation" means the batch was not acknowledged within delivery.timeout.ms (default 2 minutes), the budget for lingering, sending, retries and the ack. Inside that budget, a request with no response after request.timeout.ms (default 30 seconds) is failed as REQUEST_TIMED_OUT ("Disconnected from node 1 due to timeout") and retried, and the broker itself answers REQUEST_TIMED_OUT when an acks=all write waited longer than that timeout for the in-sync replicas. Only the request timeout carries the protocol error REQUEST_TIMED_OUT (code 7); the max.block.ms and delivery.timeout.ms cases are raised by the client and have no broker error code. Scenario 01.2.4 shows the buffer case: the third send blocks, then fails after max.block.ms. KafScale, a broker that speaks the Kafka protocol and keeps its partition leases, end offsets and consumer offsets in etcd, answers REQUEST_TIMED_OUT for its own reason: its operations docs say that while etcd is unavailable, producer and consumer-group operations get REQUEST_TIMED_OUT. That is KafScale's behaviour, not Apache Kafka's, which has no etcd. Scenario 08.2.2 shows it: with etcd stopped, produce requests and offset commits are refused with REQUEST_TIMED_OUT and retried. KafScale adds two cases. While etcd is down, a fetch gets REQUEST_TIMED_OUT as well, even at the partition's owner, because the broker cannot read the partition's end offset from etcd (KafScale issue #342, fixed by PR #352). And the KafScale proxy routes from its cache only while the cache is fresh, KAFSCALE_PROXY_BACKEND_CACHE_TTL_SEC (60 seconds by default): after that it answers every client request with REQUEST_TIMED_OUT itself, closes the connection, and its /readyz check returns 503. Scenario 08.2.4 shows the proxy going not ready. In KafScale a produce is acked only after its etcd write, so when that write fails after the segment reached S3, the producer gets REQUEST_TIMED_OUT for a record that is in S3. The next restore of the partition makes it readable, and the producer's retry writes it a second time; KafScale's operations guide says a timeout does not prove that nothing was written, and KafScale's maintainers confirmed this is intended: the segments in S3 are authoritative, and delivery is at-least-once. Scenario 08.2.5 shows the duplicate.

## Likely causes, most common first

1. **The topic or partition is not in the metadata.** The topic does not exist and auto.create.topics.enable is off on the brokers, the name is misspelled, a record names a partition number the topic does not have ("Partition 7 of topic orders with partition count 6 is not present in metadata after 60000 ms."), or no bootstrap server answers.
2. **Records are produced faster than they are delivered.** Slow or distant brokers, client quotas that throttle the producer, or an acks=all path waiting on slow followers let unacknowledged records pile up in buffer.memory. Once it is full, every send() blocks up to max.block.ms and then fails.
3. **The partition leader cannot be reached or does not answer.** The client gets metadata from a bootstrap server but cannot reach the leader: advertised.listeners resolve to an address the client cannot route to, a firewall drops the connection, or the leader is overloaded or paused. Requests time out, are retried, and the batch finally expires.
4. **acks=all waits on followers that are in sync but slow.** The leader holds the response until every in-sync replica has the batch. If that takes longer than request.timeout.ms, the request times out with REQUEST_TIMED_OUT, from the broker or from the client, and repeated timeouts end in an expired batch. When the ISR is too small instead, the error is NOT_ENOUGH_REPLICAS.
5. **KafScale (not Apache Kafka): etcd unavailable.** On a KafScale cluster, a produce request and an offset commit both need etcd. While etcd is down or unreachable, KafScale refuses them with REQUEST_TIMED_OUT (at once in the simulator, which notices the outage immediately). The producer retries, so its records are acked once etcd is back if delivery.timeout.ms has not run out; offset commits fail until then and the committed offsets stay where they were.
6. **KafScale: etcd down longer than the proxy cache.** On KafScale, once etcd has been down longer than the proxy's cache TTL, the proxy is not ready and answers every request with REQUEST_TIMED_OUT without reaching a broker. To the client it looks the same as the brokers' own REQUEST_TIMED_OUT; only the proxy's /readyz returning 503 tells the two apart. The proxy is ready again as soon as etcd answers.
7. **KafScale (not Apache Kafka): the partition's owner is frozen.** A KafScale broker that is paused (SIGSTOP, or a long garbage collection pause) answers nothing, but its partition leases stay in etcd until their 10 s TTL runs out, and the proxy keeps sending it the partition's requests. They hang until the client's request.timeout.ms fires; once the lease expires, another broker takes the partition. The simulator answers REQUEST_TIMED_OUT at once instead of waiting. Scenario 08.2.7 shows it.

## How to fix it

- Read the message first: "not present in metadata" points at the topic name, its existence or bootstrap.servers; "Failed to allocate" at throughput and buffer.memory; "Expiring N record(s)" at the path to the partition leader.
- Check the producer metrics: buffer-available-bytes and bufferpool-wait-ratio show a full buffer, record-retry-rate and record-error-rate show retries and failures, request-latency-max shows slow brokers.
- Test connectivity from the client host to every broker's advertised listener, not only to the bootstrap address.
- Keep delivery.timeout.ms at least request.timeout.ms plus linger.ms, as the producer docs ask, and long enough to ride out a leader election or a broker restart.
- Raise buffer.memory only for short bursts that the brokers absorb on average; for a lasting imbalance add partitions, brokers or producer instances, or slow the source down.
- Decide what a failed send means for the application (log and drop, resend, or stop) and handle the exception in every callback.
- On KafScale, bring etcd back: producers that are still retrying within delivery.timeout.ms are then acked, and consumers commit again.
- On KafScale, check the proxy readiness endpoint during an etcd outage: a 503 means its cache expired, and it recovers by itself when etcd is back.
- On KafScale, treat a timed-out produce as possibly written: keep enable.idempotence=true with acks=all on 2.1.0 or later, which drops the copy a retry would add; on 2.0, which has no idempotent producer, consumers have to tolerate it.
- On KafScale, find the frozen broker (a stopped process or a long garbage collection pause) and resume or restart it; otherwise its partitions take writes again once their 10 s leases expire, and producers keep retrying within delivery.timeout.ms.

## What not to do

- Setting max.block.ms or delivery.timeout.ms very high to make the exception go away: send() then blocks the calling thread for longer and failures surface later, while the cause stays.

## Does the client retry it?

The producer already retried or waited. Request timeouts and the broker's REQUEST_TIMED_OUT are retried until delivery.timeout.ms runs out, and a max.block.ms timeout means send() already waited that long for metadata or buffer space. When the exception reaches your callback, those records have failed; sending them again is the application's choice and writes a duplicate if the first attempt did reach the broker.

## Configs involved

- [`max.block.ms`](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_max.block.ms): How long send(), partitionsFor() and the transaction methods may block, waiting for metadata, for room in buffer.memory or for the transaction coordinator, before they throw a TimeoutException (default 60000, 1 minute).
- [`buffer.memory`](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_buffer.memory): The bytes the producer may hold for records waiting to be sent or still awaiting an acknowledgement (default 33554432, 32 MiB); when it is full, send() blocks for up to max.block.ms and then fails with BufferExhaustedException.
- [`delivery.timeout.ms`](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_delivery.timeout.ms): The upper bound on reporting success or failure after send() returns, covering the wait in a batch, the wait for the acknowledgement and every retry (default 120000, 2 minutes); it should be at least request.timeout.ms plus linger.ms.
- [`request.timeout.ms`](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_request.timeout.ms): How long the client waits for the response to one request before it sends it again or fails it (default 30000, 30 seconds); for a producer it should stay above the broker replica.lag.time.max.ms to avoid retries that write duplicates.
- [`linger.ms`](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_linger.ms): How long the producer waits for more records before it sends a batch that is not full (default 5 ms since Kafka 4.0, 0 before).
- [`acks`](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_acks): How many replicas must have a write before the producer counts it as sent: 0 (none), 1 (the leader only) or all (every in-sync replica, the default, and required for idempotence).
- [`retries`](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_retries): How many times the producer sends a batch again after a transient error (default 2147483647, so in practice delivery.timeout.ms ends the retrying); idempotence needs it above 0.

## Reproduce it in the simulator

- [Kafka buffer.memory and max.block.ms: producer backpressure](https://monedula.dev/kafka-simulator/scenarios/backpressure-buffer-memory/) (Backpressure: buffer.memory and max.block.ms): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=01.2.4&t=6)
- [Kafka Eligible Leader Replicas (KIP-966) in action](https://monedula.dev/kafka-simulator/scenarios/eligible-leader-replicas/) (Eligible leader replicas (KIP-966)): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=03.2.6&t=5)
- [KafScale 2.1 diskless Kafka: when etcd goes down](https://monedula.dev/kafka-simulator/scenarios/kafscale-2-etcd-outage/) (KafScale: etcd goes down): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=08.2.2&t=2)
- [KafScale 2.1 diskless Kafka: when S3 goes down](https://monedula.dev/kafka-simulator/scenarios/kafscale-2-s3-outage/) (KafScale: S3 goes down): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=08.2.3&t=1)
- [KafScale 2.1 proxy: etcd down past the 60 s cache TTL](https://monedula.dev/kafka-simulator/scenarios/kafscale-2-proxy-cache-expiry/) (KafScale: etcd down longer than the proxy cache): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=08.2.4&t=2)
- [KafScale 2.1: a Kafka producer timeout that still wrote](https://monedula.dev/kafka-simulator/scenarios/kafscale-2-failed-etcd-write/) (KafScale: a failed etcd write after a good upload): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=08.2.5&t=1)
- [KafScale 2.1 diskless Kafka: lease handover, no overwrite](https://monedula.dev/kafka-simulator/scenarios/kafscale-2-lease-handover-fencing/) (KafScale: a lease handover without an overwrite): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=08.2.6&t=3)
- [KafScale 2.1 diskless Kafka: a paused broker comes back](https://monedula.dev/kafka-simulator/scenarios/kafscale-2-paused-broker/) (KafScale: a paused broker comes back without overwriting): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=08.2.7&t=1)
- [AutoMQ diskless Kafka: a broker crash and WAL failover](https://monedula.dev/kafka-simulator/scenarios/automq-broker-crash-wal-failover/) (AutoMQ: a broker crashes and its WAL is replayed): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=09.1.2&t=1)
- [WarpStream Kafka: an Agent dies mid-commit](https://monedula.dev/kafka-simulator/scenarios/warpstream-agent-dies/) (WarpStream: an Agent dies): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=10.1.3&t=1)
- [WarpStream Kafka: the control plane goes down](https://monedula.dev/kafka-simulator/scenarios/warpstream-control-plane-down/) (WarpStream: the control plane is unreachable): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=10.1.4&t=1)
- [WarpStream Kafka Ripcord: produce without the control plane](https://monedula.dev/kafka-simulator/scenarios/warpstream-ripcord/) (WarpStream: Ripcord): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=10.1.5&t=1)
- [Redpanda Kafka leader crash: a Raft election, no replay](https://monedula.dev/kafka-simulator/scenarios/redpanda-leader-crash-election/) (Redpanda: the leader crashes, an election, nothing to replay): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=11.1.2&t=1)
- [Redpanda Kafka S3 outage: uploads time out, Raft holds](https://monedula.dev/kafka-simulator/scenarios/redpanda-object-storage-down/) (Redpanda: object storage goes down): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=11.1.3&t=2)
- [Nisshi diskless Kafka: a broker dies mid-write](https://monedula.dev/kafka-simulator/scenarios/nisshi-broker-dies/) (Nisshi: a broker dies): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=12.1.5&t=1)
- [Nisshi diskless Kafka: when PostgreSQL goes down](https://monedula.dev/kafka-simulator/scenarios/nisshi-postgresql-unavailable/) (Nisshi: PostgreSQL unavailable): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=12.1.6&t=2)
- [Ursa for Kafka broker failure: a kill and a silent broker](https://monedula.dev/kafka-simulator/scenarios/ursa-broker-dies/) (Ursa for Kafka: a broker dies, and a broker goes silent): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=13.1.4&t=1)

## Sources

- [Apache Kafka 4.4 Javadoc: TimeoutException](https://kafka.apache.org/44/javadoc/org/apache/kafka/common/errors/TimeoutException.html)
- [Apache Kafka 4.4 Javadoc: BufferExhaustedException](https://kafka.apache.org/44/javadoc/org/apache/kafka/clients/producer/BufferExhaustedException.html)
- [Apache Kafka 4.4.0 source: Errors.java (REQUEST_TIMED_OUT, code 7)](https://github.com/apache/kafka/blob/4.4.0/clients/src/main/java/org/apache/kafka/common/protocol/Errors.java)
- [Apache Kafka 4.4: producer config max.block.ms](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_max.block.ms)
- [Apache Kafka 4.4: producer config delivery.timeout.ms](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_delivery.timeout.ms)
- [Apache Kafka 4.4: producer config request.timeout.ms](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_request.timeout.ms)
- [Apache Kafka 4.4: producer config buffer.memory](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_buffer.memory)
- [Apache Kafka 4.4.0 source: KafkaProducer.java (metadata wait message)](https://github.com/apache/kafka/blob/4.4.0/clients/src/main/java/org/apache/kafka/clients/producer/KafkaProducer.java)
- [Apache Kafka 4.4.0 source: Sender.java (Expiring N record(s), request timeouts)](https://github.com/apache/kafka/blob/4.4.0/clients/src/main/java/org/apache/kafka/clients/producer/internals/Sender.java)
- [Apache Kafka 4.4.0 source: BufferPool.java (Failed to allocate)](https://github.com/apache/kafka/blob/4.4.0/clients/src/main/java/org/apache/kafka/clients/producer/internals/BufferPool.java)
- [Apache Kafka 4.4.0 source: DelayedProduce.java (broker REQUEST_TIMED_OUT for acks=all)](https://github.com/apache/kafka/blob/4.4.0/server/src/main/java/org/apache/kafka/server/purgatory/DelayedProduce.java)
- [Apache Kafka 4.4: monitoring (producer metrics)](https://kafka.apache.org/44/operations/monitoring/)
- [Apache Kafka 4.4: quotas](https://kafka.apache.org/44/design/design/#quotas)
- [KafScale 2.1.0: operations (etcd unavailable: REQUEST_TIMED_OUT)](https://github.com/KafScale/platform/blob/v2.1.0/docs/operations.md?plain=1#L556)
- [KafScale v2.1.0: proxy main.go (the cache is fresh for the TTL)](https://github.com/KafScale/platform/blob/v2.1.0/cmd/proxy/main.go#L406-L416)
- [KafScale v2.1.0: proxy main.go (not ready: REQUEST_TIMED_OUT, the connection closed)](https://github.com/KafScale/platform/blob/v2.1.0/cmd/proxy/main.go#L781-L793)
- [KafScale PR #319: proxy cache TTL](https://github.com/KafScale/platform/pull/319)
- [KafScale v2.1.0: broker main.go (the etcd write gates the ack)](https://github.com/KafScale/platform/blob/v2.1.0/cmd/broker/main.go#L2347-L2354)
- [KafScale v2.1.0: log.go (the restore adopts any indexed segment)](https://github.com/KafScale/platform/blob/v2.1.0/pkg/storage/log.go#L168-L274)
- [KafScale v2.1.0: operations (a timeout does not prove nothing was written)](https://github.com/KafScale/platform/blob/v2.1.0/docs/operations.md?plain=1#L1582-L1588)
- [KafScale v2.1.0: lease_manager.go (a lost session drops ownership)](https://github.com/KafScale/platform/blob/v2.1.0/pkg/metadata/lease_manager.go#L269-L309)

## Related

- [NotEnoughReplicasException in Kafka: causes and fixes](https://monedula.dev/kafka/troubleshooting/not-enough-replicas/)
- [KAFKA_STORAGE_ERROR in Kafka: disk failures and Inkless](https://monedula.dev/kafka/troubleshooting/kafka-storage-exception/)
- [NOT_LEADER_OR_FOLLOWER in Kafka: causes and fixes](https://monedula.dev/kafka/troubleshooting/not-leader-or-follower/)
- [COORDINATOR_NOT_AVAILABLE in Kafka: causes and fixes](https://monedula.dev/kafka/troubleshooting/coordinator-not-available/)
- [InvalidConfigurationException in Kafka: INVALID_CONFIG](https://monedula.dev/kafka/troubleshooting/invalid-configuration-exception/)
- [InvalidRequestException in Kafka: INVALID_REQUEST](https://monedula.dev/kafka/troubleshooting/invalid-request-exception/)
- [Kafka duplicate messages: causes and fixes](https://monedula.dev/kafka/troubleshooting/duplicate-messages/)
