---
title: "Schema not found (40403) in Kafka: causes and fixes"
description: "Why a Kafka consumer or producer gets Schema Registry error 40403, schema not found: unregistered versions, independent registries and mirrored ids."
url: https://monedula.dev/kafka/troubleshooting/schema-not-found/
---

# SerializationException: Schema not found (40403)

Kafka error · 40403 · not retriable.

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

## Quick answer

Every record written by a Confluent serializer carries a schema id, and the reader asked Schema Registry for an id it does not know, or a producer asked for a schema that was never registered. The usual causes are a schema registered nowhere, records mirrored from a cluster that uses a different registry, and a registry rebuilt from the wrong _schemas topic.

## What it means

The Confluent serializers write a magic byte and a four-byte schema id in front of each record. The id is only meaningful in the registry that assigned it: the leader hands out ids in order and stores them in its _schemas topic, and every instance reading that topic knows the same ids. The deserializer turns the id back into a schema with GET /schemas/ids/{id}; if the registry has no schema with that id it answers HTTP 404 with error code 40403, schema not found, and the client throws a RestClientException wrapped in a SerializationException from poll, in recent clients as a RecordDeserializationException naming the partition and offset. On the producer side, a serializer with auto.register.schemas=false looks the schema up under its subject instead of registering it; a schema that was never registered fails with 40403, or with 40401 subject not found when the subject itself does not exist, and 40402 version not found when a pinned version is missing. The more dangerous case does not raise an error. Two independent registries assign ids independently, so id 7 can mean an orders schema in one region and a payments schema in another. A record mirrored between clusters keeps its bytes, id included, and a consumer that asks the other registry either gets 40403 or, when that id happens to exist there, decodes the record with the wrong schema.

## Likely causes, most common first

1. **The schema was never registered.** A producer with auto.register.schemas=false, use.latest.version=false and no pinned version sends a schema version that CI never registered, or registered under a different subject because the subject name strategy differs. The lookup fails before any record is written.
2. **Records were mirrored between independent registries.** MirrorMaker 2, Cluster Linking or another replicator copies records from a cluster whose producers use one registry to a cluster whose consumers use another. The ids in the copied records belong to the source lineage, so the target registry does not know them, or knows them as different schemas.
3. **The registry was rebuilt or points at the wrong _schemas topic.** A registry started with a new kafkastore.topic, on a new backing cluster, or after _schemas was lost, begins numbering again from scratch. Every record written before it carries an id from the old lineage.
4. **The schema was deleted.** A hard delete of a subject version removes it from the registry. Records written with that id are still on the topic, and a consumer reading them from an earlier offset, or a new consumer reading from the beginning, gets 40403.

## How to fix it

- Ask the registry the consumer uses for the id directly, GET /schemas/ids/7 against its URL, and compare with the registry the producer used; a 40403 in one and a schema in the other confirms two lineages.
- Register schemas in CI before the producer that needs them is deployed, under the subject name the producer will use, and keep auto.register.schemas=false in production.
- For one id lineage across regions, run a follower-only registry in the disaster recovery site on a mirrored _schemas topic, with leader.eligibility=false, or use Schema Linking, or a single global registry that every region writes to.
- Back up the _schemas topic and give it replication factor 3 and min.insync.replicas=2, so a registry never has to be rebuilt from nothing.
- Prefer soft deletes, and only hard delete a schema once no topic still holds records written with it.

## What not to do

- Re-registering the schema in the other registry and hoping for the same id: it gets the next free id there, which does not match the records.
- Pointing consumers at a registry from another lineage because it happens to answer: ids that exist in both decode silently with the wrong schema.

## Does the client retry it?

No. The registry answers 40403 every time until the schema with that id exists in the registry the client asks. A producer must register the schema or change its configuration; a consumer stays on the record until the right registry answers for its id, or until the application seeks past it and skips the record.

## 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.

## Reproduce it in the simulator

- [Kafka Schema Registry down: a restarted client stops](https://monedula.dev/kafka-simulator/scenarios/sr-down-cold-clients/) (Schema Registry down: a restart stops the client): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=25.1.5&t=6)
- [Two independent Schema Registries break mirrored Kafka data](https://monedula.dev/kafka-simulator/scenarios/independent-registries/) (Two independent registries break mirrored data): [open at the moment it happens](https://monedula.dev/kafka-simulator/playground/?scenario=25.1.9&t=1)

## Sources

- [Confluent: Schema Registry serializers and deserializers (wire format, auto.register.schemas, use.latest.version)](https://docs.confluent.io/platform/current/schema-registry/fundamentals/serdes-develop/index.html)
- [Confluent: Schema Registry API reference (40401, 40402, 40403)](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 configuration reference (kafkastore.topic, leader.eligibility)](https://docs.confluent.io/platform/current/schema-registry/installation/config.html)
- [Confluent Schema Registry source: Errors.java](https://github.com/confluentinc/schema-registry/blob/master/core/src/main/java/io/confluent/kafka/schemaregistry/rest/exceptions/Errors.java)
- [Confluent Schema Registry source: RestClientException.java](https://github.com/confluentinc/schema-registry/blob/master/client/src/main/java/io/confluent/kafka/schemaregistry/client/rest/exceptions/RestClientException.java)
- [Apache Kafka 4.4 Javadoc: RecordDeserializationException](https://kafka.apache.org/44/javadoc/org/apache/kafka/common/errors/RecordDeserializationException.html)

## Related

- [Kafka SerializationException: Schema Registry unreachable](https://monedula.dev/kafka/troubleshooting/schema-registry-unavailable/)
- [Schema Registry no leader: new schemas fail in Kafka](https://monedula.dev/kafka/troubleshooting/schema-registry-no-leader/)
