Kafka Sink Connector fails Schema not found; error code 40403
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
The "Schema not found; error code: 40403" error means the Kafka Connect sink connector tried to look up a schema in Schema Registry but the schema does not exist under the expected subject name. The most common causes are producing messages without registering a schema first, a subject naming strategy mismatch between the producer and the connector, or pointing to the wrong Schema Registry instance.
How Schema Registry Works with Kafka Connect
When a Kafka producer serializes a message using the Avro, Protobuf, or JSON Schema serializer, it registers the schema with Schema Registry and embeds the schema ID in the message payload (as a 5-byte header: magic byte + 4-byte schema ID).
When the sink connector deserializes the message, it reads the schema ID from the payload and fetches the schema from Schema Registry. If Schema Registry has no schema for that ID, or the subject the connector expects does not exist, you get error 40403.
The error format <subject>-value tells you which subject the connector was looking for.
Cause 1: Schema Was Never Registered
If the producer sent messages without using a schema-aware serializer, no schema was registered. 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 configure the producer to use a schema-aware serializer:
If the subject does not exist, register the schema:
Cause 2: Subject Naming Strategy Mismatch
Schema Registry uses a subject naming strategy to determine which subject name to look up for a given topic. The default is TopicNameStrategy, which constructs the subject as <topic>-key or <topic>-value.
If the producer registered the schema under a different strategy, the connector will look 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
Ensure the producer and consumer use the same strategy:
Check which subjects actually exist:
Cause 3: Wrong Schema Registry URL
The sink connector is pointing to a different Schema Registry instance than the one the producer used.
Fix
Verify the Schema Registry URL in the connector configuration and in the Kafka Connect worker properties:
Remember that the converter-level URL (value.converter.schema.registry.url) overrides the worker-level URL.
Cause 4: Schema Deleted or Soft-Deleted
If someone deleted the schema (either hard or soft delete), the lookup fails:
Cause 5: Using value.converter Without Schema Registry
If the connector uses AvroConverter but the messages are plain JSON (not Avro-encoded), the converter tries to read the 5-byte schema ID header and fails:
Fix
Match the converter to the actual 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 |
Diagnostic Workflow
When you encounter the 40403 error, follow this sequence:
Complete Working Connector Configuration
Here is a correctly configured JDBC sink connector with all schema-related settings:
Common Pitfalls
Mixing serialization formats. Producing as JSON but consuming with AvroConverter (or vice versa) causes deserialization failures. The converter must match the actual format of messages on the topic.
Forgetting the converter prefix. The schema registry URL for the connector must be set as value.converter.schema.registry.url, not just schema.registry.url. The latter is for the worker-level config. Omitting the prefix means the converter does not know where to find schemas.
Multiple environments sharing a Schema Registry. If dev and staging topics use the same Schema Registry, subjects from one environment may not exist in another. Use separate Schema Registry instances or a prefix-based naming convention.
Not checking the connector status API. The Connect REST API at /connectors/<name>/status often contains the full stack trace with the exact subject name that failed. This is more informative than the Kafka Connect worker logs.
Assuming the schema auto-registers on the consumer side. auto.register.schemas is a producer-side setting. The consumer (sink connector) never registers schemas. It only reads them. The schema must already exist before the connector reads the message.
Ignoring key vs. value schema. The error message includes -key or -value in the subject name. Make sure you are investigating the correct side. Key schemas and value schemas are separate subjects.
Summary
Error 40403 means Schema Registry does not have the schema the sink connector needs. Check whether the schema was registered, whether the subject naming strategy matches between producer and consumer, and whether the connector points to the correct Schema Registry URL. Use the diagnostic curl commands to list subjects and inspect connector configuration. Match the converter type to the actual message serialization format on the topic. When in doubt, consume a message with kafka-avro-console-consumer to verify the message format and schema ID independently of the connector.

