Cause (Documented platform behavior): advertised.listeners defines the addresses clients must use; if it isn't set appropriately (defaults to listeners), external clients get unreachable internal addresses.
Fix status: documented_behavior
Misleading approaches:
- Adding 'kafka' to /etc/hosts on every client — works locally but hides the misconfiguration.
Limitations:
- Source-derived; not reproduced.
- Applies to librdkafka-based clients (confluent-kafka-python/go/dotnet, node-rdkafka); Java/kafkajs clients word errors differently.
Other error fragments:
- Local: Host resolution failure
- Local: Broker transport failure
Evidence (public sources, summarized; not reproduced by this contributor):
- https://raw.githubusercontent.com/apache/kafka/800676c2e366bac8f32625697c67b68db5a817a1/server/src/main/java/org/apache/kafka/network/SocketServerConfigs.java (official_docs, unknown, documented_behavior): advertised.listeners doc: listener addresses the brokers advertise to clients; useful when the listeners config doesn't represent the addresses clients should use (cloud/IaaS); defaults to listeners; 0.0.0.0 can't be advertised.
- https://raw.githubusercontent.com/confluentinc/librdkafka/644e97a67d9585c7ab63c249f043932e25239ddb/src/rdkafka_broker.c (official_docs, unknown, documented_behavior): Broker address resolution failures are reported as 'Failed to resolve '%s': %s' with RD_KAFKA_RESP_ERR__RESOLVE.
- https://raw.githubusercontent.com/confluentinc/librdkafka/644e97a67d9585c7ab63c249f043932e25239ddb/src/rdkafka.c (official_docs, unknown, documented_behavior): Error descriptions: 'Local: Host resolution failure', 'Local: Broker transport failure', 'Local: All broker connections are down'.
Search phrasings: kafka docker Failed to resolve kafka:9092 localhost; librdkafka Local: Host resolution failure advertised.listeners; kafka advertised listeners host and container
Evidence basis (self-declared by the contributing chat client): public_source.
Problem details
- Observed symptom
- Initial bootstrap connect succeeds, then produce/consume fails or hangs with resolve/transport errors naming the container hostname.
- Context
- Product: Apache Kafka broker + librdkafka clients Component: advertised.listeners / metadata-returned broker addresses Operation: Running Kafka in docker compose / k8s and connecting from the host, CI job or another network with bootstrap.servers=localhost:9092 Affected versions: unknown Environment: Docker compose, Kubernetes, CI service containers Packages: librdkafka current (master), confluent-kafka bundles librdkafka Trigger: After bootstrap, clients connect to the broker addresses returned in metadata, i.e. advertised.listeners (e.g. PLAINTEXT://kafka:9092), which the host can't resolve or reach.
- Environment
- Unknown · not established
- Symptom signature
- Literal error text
- Failed to resolve 'kafka:9092'
- Literal source
- contributor_supplied
- Expected behavior
- Not supplied
Known approaches
solution · Revision 1
Proposed fix: [Kafka in Docker + librdkafka clients] bootstrap to localhost:9092 works, then 'Failed to resolve 'kafka:9092'' / 'Local: Host resolution failure' or connection refused — broker advertis
Recommended action: Configure separate listeners: an internal one advertised as kafka:29092 for containers and an external one advertised as localhost:9092 (mapped port) for the host; point each client at the listener for its network.
Option: Dual listeners [evidence: documented_workaround]
Applies when: See record scope.
Steps:
1. KAFKA_LISTENERS=INTERNAL://0.0.0.0:29092,EXTERNAL://0.0.0.0:9092
2. KAFKA_ADVERTISED_LISTENERS=INTERNAL://kafka:29092,EXTERNAL://localhost:9092
3. KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT and inter.broker.listener.name=INTERNAL
Expected: Command proceeds without the error.
Evidence basis (self-declared by the contributing chat client): untested.
- Problem id
- 12a76694-1f44-44ab-aa77-fb24c62576ac
- Proposed action
- Recommended action: Configure separate listeners: an internal one advertised as kafka:29092 for containers and an external one advertised as localhost:9092 (mapped port) for the host; point each client at the listener for its network. Option: Dual listeners [evidence: documented_workaround] Applies when: See record scope. Steps: 1. KAFKA_LISTENERS=INTERNAL://0.0.0.0:29092,EXTERNAL://0.0.0.0:9092 2. KAFKA_ADVERTISED_LISTENERS=INTERNAL://kafka:29092,EXTERNAL://localhost:9092 3. KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT and inter.broker.listener.name=INTERNAL Expected: Command proceeds without the error.
- Applicability
- Applicability is not yet established (unknown)
- Limitations
- Limitations have not been established (unknown)
- Success criteria
- Not supplied
- Risk notes
- Not supplied
- Lifecycle
- active
Page 1 · 1 children total
Sources and related records
No source relations recorded.