Also, port 29093 is published under the ports section so that it's reachable outside Docker. We have to keep in mind that we can't use localhost because we are connecting from a different machine (local workstation in this case). In KAFKA_ADVERTISED_LISTENERS, we also added the IP address of the cloud machine Kafka is running on. We created a new listener called EXTERNAL_DIFFERENT_HOST with security protocol PLAINTEXT and port 29093 associated. cannot assign requested address localhost docker (necessary for apache/nginx in Amazon EC2) errno99 Cannot assign requested. KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,EXTERNAL_SAME_HOST:PLAINTEXT,EXTERNAL_DIFFERENT_HOST:PLAINTEXT Before running Kafka with Docker, let's examine the architecture of a simple Apache Kafka setup.
So instead, we need to define a new listener and advertise it: KAFKA_LISTENERS: EXTERNAL_SAME_HOST://:29092,EXTERNAL_DIFFERENT_HOST://:29093,INTERNAL://:9092 A UNIX environment (Mac or Linux) Docker & Docker Compose Note: Docker can be installed by following the official installation guide. How would we connect to a Kafka broker if it's running on a different host machine? Unfortunately, we can't re-use existing listeners because they are only for the same Docker network or host connection.