Monedula

Kafka troubleshooting

TopicAuthorizationException (TOPIC_AUTHORIZATION_FAILED)

Kafka error · TOPIC_AUTHORIZATION_FAILED · not retriable

org.apache.kafka.common.errors.TopicAuthorizationException

The broker's authorizer found no ACL that allows this principal the operation on the topic, so it refused the request: Write for producing, Read for consuming, Describe for metadata. Once an authorizer is configured, Kafka denies by default. Find the principal the broker actually sees and add the missing ALLOW ACL with kafka-acls.sh.

Reproduce it in the playground

The moment it happensProduce denied (no ACL). t+1.000s

p1 tries to produce to orders. No ACL grants App:orders-svc the Write operation on this topic, so the broker rejects the request with TopicAuthorizationException before any record reaches the log. The producer goes to an error state and nothing is appended.

Open at this step: step 2, Produce denied (no ACL)

What it means

On a cluster with authorizer.class.name set (in KRaft, org.apache.kafka.metadata.authorizer.StandardAuthorizer), every request is checked against ACLs made of a principal, an operation, a host and a resource pattern. A resource with no matching ACL is open only to super.users, unless allow.everyone.if.no.acl.found=true, and a matching DENY ACL wins over any number of ALLOW ACLs. A failed topic check returns TOPIC_AUTHORIZATION_FAILED (error code 29), and the client throws TopicAuthorizationException with the message "Not authorized to access topics: [orders]". A producer usually logs "Topic authorization failed for topics [orders]" while fetching metadata; a consumer logs "Not authorized to read from partition orders-0." The broker records each denial at INFO in the kafka.authorizer.logger logger, for example "Principal = User:orders-svc is Denied operation = WRITE from host = 10.0.0.5 on resource = Topic:LITERAL:orders for request = Produce ... based on rule DefaultDeny". Missing rights on the consumer group or the transactional.id raise their own errors, GroupAuthorizationException and TransactionalIdAuthorizationException. Scenario 10.5.1 shows the default deny and the ALLOW Write ACL that lifts it; 10.5.2 shows the same grant through a Confluent Platform role binding, which the built-in StandardAuthorizer does not have.

Likely causes, most common first

  1. No ACL grants the operation. Producing needs Write on the topic, consuming needs Read on the topic and on the group, and metadata or offset lookups need Describe; an ALLOW for Read, Write, Delete or Alter implies Describe. A new topic, a new service or a renamed topic has no matching ACL, so it is denied.
  2. The principal is not the one in the ACL. With TLS client authentication the default principal is the whole certificate name, such as User:CN=orders-svc,OU=Unknown,O=Unknown,L=Unknown,ST=Unknown,C=Unknown, unless ssl.principal.mapping.rules shortens it; with Kerberos it is the primary part of the principal. The principal must match exactly, and the User type is case sensitive, so an ACL for User:orders-svc does not match the full certificate name unless a mapping rule produces that name.
  3. The ACL misses the resource or the host. A literal ACL matches one exact topic name and a prefixed ACL only names that start with its prefix, so a typo or the wrong pattern type misses. An ACL limited with --allow-host matches only that client IP address, which breaks behind NAT or after a move. A matching DENY ACL overrides every ALLOW.
  4. Authorization was switched on before the ACLs existed. Setting authorizer.class.name on a running cluster without first creating ACLs for every client denies all of them, because resources without ACLs are open only to super users.

How to fix it

What not to do

Does the client retry it?

No. The same principal is denied every time until an ACL allows the operation. Once one does, a consumer and a non-transactional producer carry on without a restart. A transactional producer must at least abort the open transaction; the KafkaProducer Javadoc says to close it, which is the safe choice.

Configs involved

Reproduce it in the simulator

Sources

All troubleshooting pages