title: Not able to consume kafka events remotely Error: connect ECONNREFUSED 5.6.7.8:9092
body: <p>I have set up my kafka producer a fresh following the tutorial mentioned here: 
  <a href="https://www.digitalocean.com/community/tutorials/how-to-install-apache-kafka-on-ubuntu-14-04" rel="nofollow noreferrer">https://www.digitalocean.com/community/tutorials/how-to-install-apache-kafka-on-ubuntu-14-04</a></p>
  
  <p>I am pushing some events to the producer using cron and following script on server with IP: 1.2.3.4 </p>
  
  <pre><code>#!/usr/bin/env python
  import threading, logging, time
  import multiprocessing
  import requests
  import datetime
  import json
  from kafka import KafkaProducer
  
  class CheckApis():
      apisList = {"a": "https://test.eng.com/"}
      kafkaProducer = "1.2.3.4:9092"
      kafkaTopic = "sometopic"
      producer = KafkaProducer(bootstrap_servers=kafkaProducer)
      for key, value in apisList.items():
          headers = {};
          response = requests.request("GET", value, headers=headers)
          message = {"app_name": key, "status": response.status_code, "message": "none", "timestamp": str(datetime.datetime.utcnow())}
          producer.send(kafkaTopic, json.dumps(message).encode('utf-8'));
          print (response.text)
          print (response.status_code)
      producer.close()
  </code></pre>
  
  <p>This works well, and I can see the pushed events using this command:</p>
  
  <pre><code>~/kafka/bin/kafka-console-consumer.sh --zookeeper 1.2.3.4:2181 --topic sometopic --from-beginning
  </code></pre>
  
  <p>But when I try to use these events remotely from other server (my laptop), it fails with error: </p>
  
  <blockquote>
    <p>error: Some error occured while listening to kafka events Error:
    connect ECONNREFUSED 5.6.7.8:9092 (Some different IP here not 1.2.3.4)</p>
  </blockquote>
  
  <p>Here is my consumer code (in node js using kafka-node):</p>
  
  <pre><code>var ConsumerGroup = require('kafka-node').ConsumerGroup;
      var healthConsumerOption = {
          host: '1.2.3.4:2181',
          autoCommit: true,
          groupId: os.hostname(),
          sessionTimeout: 15000,
          protocol: ['roundrobin'],
          fromOffset: 'latest'
      };
      var healthConsumerGroup = new ConsumerGroup(healthConsumerOption, healthTopics);
          listenHealthEventsKafka: function(connections){
              try{
                  healthConsumerGroup.on('error', onError);
                  healthConsumerGroup.on('message', onMessage);
                  healthConsumerGroup.on('connect', function(){
                      logger.info("Health consumer group is ready. ")
                  });
  
                  function onMessage(message){
                      var jsonData = JSON.parse(message.value);
                      console.log(message);
                  };
  
                  function onError(error){
                      logger.error("Some error occured while listening to kafka events " +error);
                  }
  
                  process.once('SIGNINT', function(){
                      async.each([healthConsumerGroup], function(consumer, callback){
                          logger.info("Closing the kafka health consumer process ");
                          consumer.close(true, callback);
                      });
                  })
              }catch(error){
                  logger.error("Could not connect to kafka events for build " +error);
              }
          }
  </code></pre>
  
  <p>Do I need to do additional configuration on Kafka server (server.properties) to allow remote access.. or I am doing anything wrong? Please help.</p>