title: dial tcp: lookup ip-x-x-xx.ec2.internal: no such host
body: <p>I am using github.com/Shopify/sarama package to interact with Kafka. In my current approach I could connect to the broker and get all topic names without a problem <em>(Consumer Code below)</em>. </p>
  
  <p>However, when I try to delete some topic using the admin client <em>(Admin Code below)</em> I receive the "dial tcp: lookup ip-x-x-xx.ec2.internal: no such host" error.</p>
  
  <p>I am out of ideas why I do receive this error. I would much appreciate any hints or possible solutions.</p>
  
  <p><strong>Consumer</strong></p>
  
  <pre class="lang-golang prettyprint-override"><code>
      config := sarama.NewConfig()
      config.Consumer.Return.Errors = true
  
      //get broker
      cluster, err := sarama.NewConsumer("localhost:9092", config)
      if err != nil {
          panic(err)
      }
  
      defer func() {
          if err := cluster.Close(); err != nil {
              panic(err)
          }
      }()
  
      //get all topic from cluster
      topics, _ := cluster.Topics()
  
  </code></pre>
  
  <p><strong>Admin</strong></p>
  
  <pre class="lang-golang prettyprint-override"><code>
      config := sarama.NewConfig()
      config.Consumer.Return.Errors = true
  
      config.Version = sarama.V2_4_0_0
  
      //admin broker
      admin, err := sarama.NewClusterAdmin("localhost:9092", config)
      if err != nil {
          panic(err)
      }
  
  
      defer func() {
          if err := admin.Close(); err != nil {
              panic(err)
          }
      }()
  
      topic := []string{"test-topic"}
      output := admin.DeleteTopic(topic)
  
      if output == nil {
          fmt.Printf(" delete -  %s\n", topic[0])
      } else {
          fmt.Println(output)
      }
  </code></pre>
  
  <p><strong>Note</strong> I am connecting over bastion instance into a remote by forwarding ssh ports.</p>
  
  <hr>
  
  <h1>Update</h1>
  
  <p>after setting <code>sarama.Logger = log.New(os.Stdout, "[sarama] ", log.LstdFlags)</code> I get the following:</p>
  
  <pre><code>[sarama] 2020/03/25 02:08:03 Initializing new client
  [sarama] 2020/03/25 02:08:03 client/metadata fetching metadata for all topics from broker localhost:9092
  [sarama] 2020/03/25 02:08:04 Connected to broker at localhost:9092 (unregistered)
  [sarama] 2020/03/25 02:08:04 client/brokers registered new broker #1001 at ip-x-x-x-1.ec2.internal:9092
  [sarama] 2020/03/25 02:08:04 client/brokers registered new broker #1003 at ip-x-x-x-2.ec2.internal:9092
  [sarama] 2020/03/25 02:08:04 client/brokers registered new broker #1002 at ip-x-x-x-3.ec2.internal:9092
  [sarama] 2020/03/25 02:08:04 Successfully initialized new client
  [sarama] 2020/03/25 02:08:04 Failed to connect to broker ip-x-x-x-3.ec2.internal:9092: dial tcp: lookup ip-x-x-x-3.ec2.internal: no such host`
  </code></pre>
  
  <hr>
  
  <h1>Update 2</h1>
  
  <p>my kafka server.properties:</p>
  
  <pre><code>advertised.listeners=INTERNAL://ip-x-x-x-1.ec2.internal:9091,EXTERNAL_INSECURE://ip-x-x-x-1.ec2.internal:9092
  listeners=INTERNAL://:9091,EXTERNAL_INSECURE://:9092
  listener.security.protocol.map=INTERNAL:SSL,EXTERNAL_INSECURE:PLAINTEXT
  </code></pre>