Skip to main content
Learn how to configure advertised listeners for client connectivity in 10 minutes The advertised listeners setting is one of the most important Kafka configurations. Mis-configuring it is a common cause of client connection failures. What you’ll learn:
  • How Kafka clients discover and connect to brokers
  • Why advertised host configuration matters
  • How to configure advertised listeners for different network topologies
  • Common pitfalls and how to avoid them

Connecting to a Kafka cluster

When a client connects to a Kafka cluster, the broker responds with the advertised host that the client MUST use for all future communications - regardless of how the initial connection was made.
Common misconceptionJust because a Kafka hostname and port are reachable doesn’t mean clients can establish a Kafka-protocol connection. The client has to be able to reach the advertised address, not just the initial bootstrap address.

Setting advertised host as localhost

If you set the Advertised Host as localhost, the Kafka client will successfully connect to the cluster if it is running on the same machine as the broker.

Setting advertised host as public IP

If you set the Advertised Host as the broker’s Public IP, the Kafka client will successfully connect to the cluster as long as the Public IP doesn’t change. It may change if the broker re-boots. If that happens, the connection cannot be re-established.

Configure advertised host

Client locationRecommended setting
Same network as brokerInternal private IP or DNS hostname
Public networkExternal public IP or DNS hostname
Both internal and externalConfigure multiple listeners

Example: Internal clients only

listeners=PLAINTEXT://0.0.0.0:9092
advertised.listeners=PLAINTEXT://internal-broker1.company.com:9092

Example: External clients only

listeners=PLAINTEXT://0.0.0.0:9092
advertised.listeners=PLAINTEXT://public-broker1.example.com:9092

Example: Both internal and external clients

listeners=INTERNAL://0.0.0.0:9092,EXTERNAL://0.0.0.0:9093
advertised.listeners=INTERNAL://internal-broker1.company.com:9092,EXTERNAL://public-broker1.example.com:9093
listener.security.protocol.map=INTERNAL:PLAINTEXT,EXTERNAL:SSL
Use DNS hostnamesPrefer DNS hostnames over IP addresses. IP addresses can change when instances reboot, but DNS can be updated to point to new addresses without client configuration changes.
For an in-depth explanation of Kafka Listeners, see Kafka Listeners Explained.
See it in practice with ConduktorConduktor Console displays broker listener configurations and helps diagnose connectivity issues. Test connections from different network locations to verify your advertised listener settings.

Next steps