kafka network_error ai_generated true

java.io.IOException: 无法连接到节点 -1 (localhost/127.0.0.1:9092)。代理可能不可用。

java.io.IOException: Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.common.errors.TimeoutException)

ID: kafka/network-exception-read-returned-negative

其他格式: JSON · Markdown 中文 · English
85%修复率
85%置信度
1证据数
2023-04-12首次发现

版本兼容性

版本状态引入弃用备注
Kafka 2.8.0 active
Kafka 3.0.0 active
Kafka 3.4.0 active

根因分析

Kafka 客户端无法与代理建立 TCP 连接,通常是由于网络配置错误或代理宕机。

English

The Kafka client cannot establish a TCP connection to the broker, often due to network misconfiguration or broker downtime.

generic

官方文档

https://kafka.apache.org/documentation/#broker_not_available

解决方案

  1. Verify broker availability by running `telnet localhost 9092` or `nc -zv localhost 9092` to ensure the port is open. Then check broker logs for errors.
  2. Update `bootstrap.servers` in the producer/consumer configuration to point to a correct, reachable broker list (e.g., `bootstrap.servers=broker1:9092,broker2:9092`).

无效尝试

常见但无效的做法:

  1. Restarting the Kafka client without checking broker health 90% 失败

    The underlying broker issue (e.g., crash, network partition) remains unresolved, so the error recurs.

  2. Increasing `request.timeout.ms` to a very high value 70% 失败

    A timeout extension does not fix the connection failure; it only delays the error message.