title: Socket server failed to bind to kafka:29092: Cannot assign requested address
body: <p>I am trying to create a kafka server from the following yaml file:</p>
  <pre class="lang-yaml prettyprint-override"><code>version: &quot;3.9&quot;
  
  services:
    zookeeper:
      image: 'bitnami/zookeeper:latest'
      ports:
        - '2181:2181'
      environment:
        - ALLOW_ANONYMOUS_LOGIN=yes
  
    kafka:
      image: 'bitnami/kafka:latest'
      ports:
        - '9092:9092'
      environment:
        - KAFKA_BROKER_ID=1
        - ALLOW_PLAINTEXT_LISTENER=yes
        - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
        - KAFKA_LISTENERS=PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
        - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
        - KAFKA_INTER_BROKER_LISTENER_NAME=PLAINTEXT
        - KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
      depends_on:
        - zookeeper
  </code></pre>
  <p>But I am getting an error:</p>
  <pre><code>ERROR [KafkaServer id=1] Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
  org.apache.kafka.common.KafkaException: Socket server failed to bind to kafka:29092: Cannot assign requested address.
      at kafka.network.Acceptor.openServerSocket(SocketServer.scala:667)
      at kafka.network.Acceptor.&lt;init&gt;(SocketServer.scala:560)
      at kafka.network.SocketServer.createAcceptor(SocketServer.scala:288)
      at kafka.network.SocketServer.$anonfun$createDataPlaneAcceptorsAndProcessors$1(SocketServer.scala:261)
      at kafka.network.SocketServer.$anonfun$createDataPlaneAcceptorsAndProcessors$1$adapted(SocketServer.scala:259)
      at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:62)
      at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:55)
      at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:49)
      at kafka.network.SocketServer.createDataPlaneAcceptorsAndProcessors(SocketServer.scala:259)
      at kafka.network.SocketServer.startup(SocketServer.scala:131)
      at kafka.server.KafkaServer.startup(KafkaServer.scala:296)
      at kafka.Kafka$.main(Kafka.scala:109)
      at kafka.Kafka.main(Kafka.scala)
  Caused by: java.net.BindException: Cannot assign requested address
      at java.base/sun.nio.ch.Net.bind0(Native Method)
      at java.base/sun.nio.ch.Net.bind(Net.java:455)
      at java.base/sun.nio.ch.Net.bind(Net.java:447)
      at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
      at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
      at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:73)
      at kafka.network.Acceptor.openServerSocket(SocketServer.scala:663)
      ... 12 more
  </code></pre>
  <p>What is wrong with my configuration?</p>