Kafka send message error: {"level":"ERROR","timestamp":"2026-01-05T10:58:00.087Z","logger":"kafkajs","message":"[BrokerPool] Closed connection","retryCount":0,"retryTime":270}

Describe the problem/error/question

kafka send message node Errors occur frequently
{“level”:“ERROR”,“timestamp”:“2026-01-05T10:58:00.087Z”,“logger”:“kafkajs”,“message”:“[BrokerPool] Closed connection”,“retryCount”:0,“retryTime”:270}

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 2.1.5
  • Database (default: SQLite):SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main):own
  • Running n8n via (Docker, npm, n8n cloud, desktop app):desktop
  • Operating system: win
1 Like

hello @lironghai

Is something not working? The broker may close connections; it depends on the broker’s settings.

Yes, I am using the cron node to trigger the sending of Kafka messages, which is executed every 10 seconds. After executing several times, a Closed connection error occurs, causing the message sending to fail. However, the same connection configuration runs normally in the code. I don’t know what is causing this issue

Try changing the timeout to something more than 30 seconds.

Are you connecting to the single kafka service or a cluster?

Yes, currently, the default expiration time is set to 30 seconds. The Kafka target I am linking to is a cluster, but the link address is forwarded using a proxy. One proxy address is used to proxy multiple broker addresses, so only one proxy address is configured in the Kafka credentials for the broker. I think this linking method is the cause. I would like to know whether the Kafka message sending node creates a new link each time it runs or reuses links from the link pool

As I see in the code, the node initiates a new connection to the Kafka service, sends a message, and then disconnects. Most probably, you have some network limitations (not sure where exactly).

import { CompressionTypes, Kafka as apacheKafka } from 'kafkajs'

const kafka = new apacheKafka(config)
const producer = kafka.producer()
await producer.connect()
await producer.sendBatch()
await producer.disconnect()