Kafka
Topic Authorization
Software Troubleshooting
Programming Errors
Data Security

Kafka TOPIC_AUTHORIZATION_FAILED: causes and fix

Codemia Knowledge Hub ·

TOPIC_AUTHORIZATION_FAILED means the Kafka client's principal does not have the ACL permission required for the operation it attempted on a topic. Find out which principal the client is using, check the topic's ACLs, and grant the missing permission with kafka-acls.sh.

When the error appears

  1. Producing: the client sends to a topic without "write" permission.
  2. Consuming: the client reads from a topic without "read" permission.
  3. Managing topics: the client creates, deletes or alters a topic without the matching "create", "delete" or "alter" permission.

The broker checks every request with an Authorizer class configured in its server settings, which compares the request against Access Control Lists (ACLs) set by administrators.

How Kafka ACLs work

ACLs define what a user or group can do on topics, consumer groups or the cluster. This command grants a user read access to a topic:

bash
bin/kafka-acls.sh --bootstrap-server broker:9092 --command-config admin.properties --add --allow-principal User:username --operation Read --topic topicname

admin.properties holds the admin client's security settings. The broker's authorizer is set with authorizer.class.name in server.properties: org.apache.kafka.metadata.authorizer.StandardAuthorizer on KRaft clusters, or kafka.security.authorizer.AclAuthorizer, which stores ACLs in ZooKeeper, on older ZooKeeper-based clusters.

Fixing the error

  1. Confirm the identity: find out which user or principal is performing the operation.
  2. Check the ACLs for the topic and make sure the needed permission is granted for that action.
  3. Read the Kafka logs: they record authorization decisions and show which permission was denied.
  4. Update the ACLs to add any missing permission.

Producer and consumer cases

  • Producer gets TOPIC_AUTHORIZATION_FAILED: give the producer's principal write permission on the topic.
  • Consumer gets TOPIC_AUTHORIZATION_FAILED: give the consumer's principal read permission on the topic.

Permissions by operation

ComponentRequired PermissionCommon CausesResolution Steps
Producing MessagesWriteACL does not include write accessAdd write permission to the ACL
Consuming MessagesReadNo read access in ACLGrant read access through ACL update
Managing TopicsCreate, Delete, AlterInsufficient management permissionsAdjust ACLs to include necessary permissions

Review permissions regularly and adjust them as clients change, so authorized clients keep working and unauthorized ones stay out.


Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design