Kafka sink connector fails: Schema not found; error code: 40403
Codemia Knowledge Hub ·
"Schema not found; error code: 40403" means the Kafka Connect sink connector looked up a schema in Schema Registry and it does not exist under the expected subject. The usual causes are messages produced without registering a schema, a subject naming strategy that differs between producer and connector, or a connector pointed at the wrong Schema Registry instance.
How the connector looks up schemas
A producer using the Avro, Protobuf or JSON Schema serializer registers the schema with Schema Registry and embeds the schema ID in the message payload as a 5-byte header (magic byte plus 4-byte schema ID).
When the sink connector deserializes the message, it reads that ID and fetches the schema from Schema Registry. If there is no schema for that ID, or the subject the connector expects does not exist, you get 40403:
The <subject>-value part of the message tells you which subject the connector was looking for.
Cause 1: the schema was never registered
No schema gets registered when the producer does not use a schema-aware serializer. This happens when:
- The producer uses
StringSerializerorByteArraySerializerinstead ofKafkaAvroSerializer - The producer was configured with
auto.register.schemas=falseand no schema was pre-registered - The topic received data from a source that does not interact with Schema Registry
Fix: register the schema manually, or switch the producer to a schema-aware serializer. First see what exists:
If the subject is missing, register the schema:
Cause 2: subject naming strategy mismatch
The subject naming strategy decides which subject name is used for a topic. The default, TopicNameStrategy, uses <topic>-key or <topic>-value. If the producer registered the schema under a different strategy, the connector looks for a subject that does not exist.
| Strategy | Subject Name Format | Use Case |
TopicNameStrategy (default) | <topic>-value | One schema per topic |
RecordNameStrategy | <fully.qualified.RecordName> | Multiple record types per topic |
TopicRecordNameStrategy | <topic>-<fully.qualified.RecordName> | Multiple record types, scoped per topic |
Fix: use the same strategy on the producer and the connector:
Then check which subjects actually exist:
Cause 3: wrong Schema Registry URL
The connector points at a different Schema Registry instance than the producer used:
Fix: check the URL in both the connector configuration and the Connect worker properties, and confirm the registry is reachable from the worker:
The converter-level URL (value.converter.schema.registry.url) overrides the worker-level URL.
Cause 4: the schema was deleted or soft-deleted
A hard or soft delete of the schema makes the lookup fail:
Cause 5: AvroConverter reading plain JSON
If the connector uses AvroConverter but the messages are plain JSON rather than Avro-encoded, the converter tries to read the 5-byte schema ID header and fails:
Fix: match the converter to the real message format:
| Message Format | Correct Converter |
| Avro (with Schema Registry) | io.confluent.connect.avro.AvroConverter |
| JSON with schema | org.apache.kafka.connect.json.JsonConverter (schemas.enable=true) |
| Plain JSON | org.apache.kafka.connect.json.JsonConverter (schemas.enable=false) |
| Protobuf | io.confluent.connect.protobuf.ProtobufConverter |
| String | org.apache.kafka.connect.storage.StringConverter |
Step-by-step diagnosis
Work through these checks in order. Consuming a message with kafka-avro-console-consumer verifies the message format and schema ID independently of the connector.
A working JDBC sink configuration
A JDBC sink connector with all schema-related settings configured correctly:
Mistakes that cause 40403
Mixing serialization formats. Producing JSON and consuming with AvroConverter (or the reverse) breaks deserialization. The converter must match the format actually on the topic.
Forgetting the converter prefix. Set the connector's registry URL as value.converter.schema.registry.url, not just schema.registry.url, which is for the worker-level config. Without the prefix the converter does not know where the schemas are.
Sharing one Schema Registry across environments. If dev and staging topics share a registry, subjects from one environment may be missing in another. Use separate registries or a prefix-based naming convention.
Skipping the connector status API. /connectors/<name>/status in the Connect REST API often holds the full stack trace with the exact subject that failed, which is more useful than the worker logs.
Expecting the consumer to register schemas. auto.register.schemas is a producer-side setting. The sink connector only reads schemas and never registers them, so the schema must exist before the connector reads the message.
Confusing key and value schemas. The subject in the error ends in -key or -value. They are separate subjects, so investigate the right one.
Related reading
- Kafka sink connector No tasks assigned, even after restart
- Kafka SMT ValueToKey - How use multiple values as key?
- Kafka Source Connect does not seem to do anything
- Kafka Spark streaming unable to read messages
- Kafka Spring Integration Headers not coming for kafka consumer
- Kafka SSL connection error
- Kafka, Spring Kafka and redelivering old messages
- Kafka SSL handshake failed issue
System design interview problems on this topic
- Design a Distributed Messaging System: solution and walkthrough
- Design a Log Collection and Analysis System: solution and walkthrough
- Design an Ad Click Aggregation System: solution and walkthrough
- Design a Webhook Notification Service: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.