Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available

I’m running the confluent platform in wsl 2(Ubuntu Distribution) and I also running a Spring application on Windows but when I send a message with a producer I have this error:

Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. Bootstrap broker localhost:9092 (id: -1 rack: null) disconnected

I have a look this articles:

and

and

but I don’t find the solution.

How is the configuration in confluent/etc/kafka/server.properties file?

I set this configuration:

advertised.listeners=PLAINTEXT://127.0.0.1:9092
listener.security.protocol.map=PLAINTEXT:PLAINTEXT
listeners=PLAINTEXT://0.0.0.0:9092

But It doesn’t work my spring boot application on Windows…

With this command I can see all is ok:
confluent local services status

Kafka is running on: “localhost:9092” and within WSL2 I can send (producer) and read messages (consumer) correctly but it doesn’t work my spring boot application on Windows.

Could you please advice how to solve this error?
Thanks in advance!

With the command

ip addr | grep eth0

on Ubuntu terminal I can get external interface IP, I set this IP on advertised.listener and with the command

netsh interface portproxy add v4tov4 listenport=9092 listenaddress=0.0.0.0 connectport=9092 connectaddress=XXX.XX.XX.XX

being XXX.XX.XX.XX the external interface IP and put this command on Windows cmd I can forward ports.

With the command netstat -ab I can see on Windows cmd the IP and Port TCP 0.0.0.0:9092. It works correctly!

@davidleongz glad you got it fixed, and thanks for taking the time to share the solution :+1:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.