title: Kafka.JS refuses to connect <<[BrokerPool] Failed to connect to seed broker, trying another broker from the list>>
body: <p>Consider the Kafka Producer :</p>
  <pre><code>const { Kafka, logLevel } = require('kafkajs');
  
  const kafka = new Kafka({
    clientId: 'my-app',
    brokers: ['kafka1:9092', 'kafka2:9092'],
    logLevel: logLevel.ERROR,
  });
  
  const run = async () =&gt; {
    const producer = kafka.producer();
  
    await producer.connect();
    await producer.send({
      topic: 'test-topic',
      messages: [{ value: 'Hello KafkaJS user!' }],
    });
  
    await producer.disconnect();
  };
  
  run();
  </code></pre>
  <p>Whenever I hit : node producer.js  , the response is :</p>
  <pre><code>C:\Development-T410\Kafka&gt;node producer
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:07.646Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[Connection] Connection timeout&quot;,&quot;broker&quot;:&quot;kafka1:9092&quot;,&quot;clientId&quot;:&quot;my-app&quot;}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:07.674Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout&quot;,&quot;retryCount&quot;:0,&quot;retryTime&quot;:325}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:09.004Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[Connection] Connection timeout&quot;,&quot;broker&quot;:&quot;kafka2:9092&quot;,&quot;clientId&quot;:&quot;my-app&quot;}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:09.006Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout&quot;,&quot;retryCount&quot;:1,&quot;retryTime&quot;:630}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:10.639Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[Connection] Connection timeout&quot;,&quot;broker&quot;:&quot;kafka1:9092&quot;,&quot;clientId&quot;:&quot;my-app&quot;}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:10.640Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout&quot;,&quot;retryCount&quot;:2,&quot;retryTime&quot;:1228}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:12.871Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[Connection] Connection timeout&quot;,&quot;broker&quot;:&quot;kafka2:9092&quot;,&quot;clientId&quot;:&quot;my-app&quot;}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:12.872Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout&quot;,&quot;retryCount&quot;:3,&quot;retryTime&quot;:2104}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:13.464Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[Connection] Connection error: getaddrinfo ENOTFOUND kafka1&quot;,&quot;broker&quot;:&quot;kafka1:9092&quot;,&quot;clientId&quot;:&quot;my-app&quot;,&quot;stack&quot;:&quot;Error: getaddrinfo ENOTFOUND kafka1\n    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)&quot;}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:14.789Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[Connection] Connection error: getaddrinfo ENOTFOUND kafka2&quot;,&quot;broker&quot;:&quot;kafka2:9092&quot;,&quot;clientId&quot;:&quot;my-app&quot;,&quot;stack&quot;:&quot;Error: getaddrinfo ENOTFOUND kafka2\n    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)&quot;}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:15.722Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[Connection] Connection error: getaddrinfo ENOTFOUND kafka1&quot;,&quot;broker&quot;:&quot;kafka1:9092&quot;,&quot;clientId&quot;:&quot;my-app&quot;,&quot;stack&quot;:&quot;Error: getaddrinfo ENOTFOUND kafka1\n    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)&quot;}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:15.978Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[Connection] Connection timeout&quot;,&quot;broker&quot;:&quot;kafka1:9092&quot;,&quot;clientId&quot;:&quot;my-app&quot;}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:15.979Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout&quot;,&quot;retryCount&quot;:4,&quot;retryTime&quot;:4610}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:17.059Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[Connection] Connection error: getaddrinfo ENOTFOUND kafka2&quot;,&quot;broker&quot;:&quot;kafka2:9092&quot;,&quot;clientId&quot;:&quot;my-app&quot;,&quot;stack&quot;:&quot;Error: getaddrinfo ENOTFOUND kafka2\n    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)&quot;}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:17.980Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[Connection] Connection error: getaddrinfo ENOTFOUND kafka1&quot;,&quot;broker&quot;:&quot;kafka1:9092&quot;,&quot;clientId&quot;:&quot;my-app&quot;,&quot;stack&quot;:&quot;Error: getaddrinfo ENOTFOUND kafka1\n    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)&quot;}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:21.593Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[Connection] Connection timeout&quot;,&quot;broker&quot;:&quot;kafka2:9092&quot;,&quot;clientId&quot;:&quot;my-app&quot;}
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:21.594Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[BrokerPool] Failed to connect to seed broker, trying another broker from the list: Connection timeout&quot;,&quot;retryCount&quot;:5,&quot;retryTime&quot;:8310}
  (node:9624) UnhandledPromiseRejectionWarning: KafkaJSNonRetriableError
    Caused by: KafkaJSConnectionError: Connection timeout
      at Timeout.onTimeout [as _onTimeout] (C:\Development-T410\Kafka\node_modules\kafkajs\src\network\connection.js:165:23)
      at listOnTimeout (internal/timers.js:549:17)
      at processTimers (internal/timers.js:492:7)
  (Use `node --trace-warnings ...` to show where the warning was created)
  (node:9624) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
  (node:9624) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  {&quot;level&quot;:&quot;ERROR&quot;,&quot;timestamp&quot;:&quot;2020-10-09T08:24:22.857Z&quot;,&quot;logger&quot;:&quot;kafkajs&quot;,&quot;message&quot;:&quot;[Connection] Connection error: getaddrinfo ENOTFOUND kafka2&quot;,&quot;broker&quot;:&quot;kafka2:9092&quot;,&quot;clientId&quot;:&quot;my-app&quot;,&quot;stack&quot;:&quot;Error: getaddrinfo ENOTFOUND kafka2\n    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)&quot;}
  </code></pre>
  <p>Any idea how to solve this ?</p>