---
title: "Schema Registry no leader: new schemas fail in Kafka"
description: "Why registering a new schema fails with 50004, 50003, 50002 or 50001 when Schema Registry has no leader or cannot write the Kafka _schemas topic."
url: https://monedula.dev/kafka/troubleshooting/schema-registry-no-leader/
---

# SerializationException: Schema Registry has no leader (50004, 50003)

Kafka error · 50004 / 50003 / 50002 / 50001 · not retriable.

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

## Quick answer

Only the Schema Registry leader writes new schemas, and it writes them to the _schemas topic on Kafka. With no leader elected (50004), a leader the instance cannot forward to (50003), or a leader that cannot write _schemas in time (50002, 50001), registering a genuinely new schema fails. Lookups and already registered schemas keep working.

## What it means

A Schema Registry cluster is a set of instances that elect one leader through the Kafka group protocol: they join a group on the backing Kafka cluster, named schema-registry by default, and only instances with leader.eligibility=true can win. The leader is the only writer. It appends each new schema to the compacted topic named by kafkastore.topic, _schemas by default, producing with acks=all, and every instance, the leader included, rebuilds its in-memory registry by reading that topic. Reads are therefore local: any instance answers GET /schemas/ids/{id} or a lookup under a subject from memory. A registration, POST /subjects/{subject}/versions, first looks the schema up under the subject, so a schema that is already registered gets its existing id from whichever instance received the request, without the leader. Only a genuinely new schema, or a new subject, is forwarded to the leader. That is where it breaks. With no eligible instance alive, or with the instances unable to reach Kafka to run the election, there is no leader and the registry answers error code 50004, unknown leader. If a leader exists but the instance cannot forward the request to it, the answer is 50003. If the leader cannot get its write acknowledged on _schemas within kafkastore.timeout.ms, for example because _schemas has fewer in-sync replicas than its min.insync.replicas, it answers 50002, operation timed out, or 50001 for another backend store error. The client receives a RestClientException carrying the code, and the serializer wraps it in a SerializationException thrown from send.

## Likely causes, most common first

1. **No leader-eligible instance is running.** All instances with leader.eligibility=true are down, or every instance in the surviving location was deployed with leader.eligibility=false, as a follower-only standby. The followers keep answering lookups from memory, but nothing can register a new schema.
2. **The registry cannot reach its Kafka cluster.** The election runs through a group on the backing Kafka cluster and the leader writes to _schemas on it. Lose that cluster, or the network to it, and no leader can be elected or write, even if every registry instance is healthy.
3. **The _schemas topic cannot take an acks=all write.** If _schemas was created with replication factor 1, or its in-sync replicas fall below its min.insync.replicas after a broker failure, the leader write is not acknowledged within kafkastore.timeout.ms and registration fails with 50002 or 50001.
4. **Followers cannot forward to the leader.** A request that lands on a follower is forwarded over HTTP to the leader. A leader that advertises an address the followers cannot reach, through host.name or listeners, or a firewall between instances, gives 50003 while the leader itself works.

## How to fix it

- Run more than one leader-eligible instance wherever registration must survive a failure, and check which instance is leader; the registry logs the election result, and the leader is the one whose writes reach _schemas.
- Check the backing cluster and the topic: kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic _schemas shows the replicas and the ISR. Give _schemas replication factor 3 and set min.insync.replicas=2 on it yourself; Schema Registry does not set min.insync.replicas.
- Register schemas in CI or a deploy step and run production producers with auto.register.schemas=false, so a leader outage never blocks a release that only uses schemas registered earlier.
- For a planned failover to a standby location, make its _schemas copy writable and restart the standby instances with leader.eligibility=true, so one of them becomes leader there.
- Make sure every instance advertises an address the others can reach, so a follower can forward a registration to the leader.

## What not to do

- Pointing a second registry at a different _schemas topic to get writes working again: it starts its own id lineage, and its ids collide with the old ones.
- Treating the outage as total: lookups and warm clients still work, so restarting healthy producers only adds cache misses.

## Does the client retry it?

Not by the producer: the serializer throws inside send, before the record is batched. The registration succeeds once an instance is leader again and can write to _schemas, so the application can retry the send then. Records with schemas the registry already holds keep flowing the whole time.

## Configs involved

- [`min.insync.replicas`](https://kafka.apache.org/44/configuration/topic-configs/#topicconfigs_min.insync.replicas): The fewest in-sync replicas, leader included, that must have a write for an acks=all produce to succeed (default 1); with fewer in the ISR the leader rejects the write with NOT_ENOUGH_REPLICAS.
- [`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).

## Reproduce it in the simulator

- [Schema Registry across two DCs: losing the leader DC](https://monedula.dev/kafka-simulator/scenarios/sr-stretched-dc-loss/) (SR across two DCs: losing the leader's DC): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=25.1.7&t=4)
- [Schema Registry DR: failover to a follower-only registry](https://monedula.dev/kafka-simulator/scenarios/sr-follower-region-failover/) (SR across regions: failover to the DR registry): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=25.1.8&t=5)

## Sources

- [Confluent: running Schema Registry in production (leader election, leader.eligibility)](https://docs.confluent.io/platform/current/schema-registry/installation/deployment.html)
- [Confluent: Schema Registry configuration reference (kafkastore.topic, kafkastore.timeout.ms)](https://docs.confluent.io/platform/current/schema-registry/installation/config.html)
- [Confluent: Schema Registry API reference (error codes)](https://docs.confluent.io/platform/current/schema-registry/develop/api.html)
- [Confluent: multi-datacenter Schema Registry](https://docs.confluent.io/platform/current/schema-registry/multidc.html)
- [Confluent Schema Registry source: Errors.java (50001 to 50004)](https://github.com/confluentinc/schema-registry/blob/master/core/src/main/java/io/confluent/kafka/schemaregistry/rest/exceptions/Errors.java)
- [Confluent Schema Registry source: KafkaSchemaRegistry.java (lookup before forwarding a registration)](https://github.com/confluentinc/schema-registry/blob/master/core/src/main/java/io/confluent/kafka/schemaregistry/storage/KafkaSchemaRegistry.java)

## Related

- [Kafka SerializationException: Schema Registry unreachable](https://monedula.dev/kafka/troubleshooting/schema-registry-unavailable/)
- [Schema not found (40403) in Kafka: causes and fixes](https://monedula.dev/kafka/troubleshooting/schema-not-found/)
- [NotEnoughReplicasException in Kafka: causes and fixes](https://monedula.dev/kafka/troubleshooting/not-enough-replicas/)
