Springboot连接Kafka服务器 报错 Connection to node -1 could not be established. Broker may not be available

springboot项目启动报错:Connection to node -1 could not be established. Broker may not be available

可能原因:

1.服务器上kafka的config目录下的server.properties配置导致9092端口未被正确监听

下面三项参数重点注意

 

advertised.host.name必须写kafka服务器的ip地址!如果写localhost,并且项目运行的服务器和kafka运行的不是同一台服务器,会连接不上。