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

**URL:** <https://forum.confluent.io/t/connection-to-node-1-localhost-127-0-0-1-9092-could-not-be-established-broker-may-not-be-available/4512>\
**Category:** Clients\
**Created:** [21 March 2022 16:02 UTC](https://forum.confluent.io/t/connection-to-node-1-localhost-127-0-0-1-9092-could-not-be-established-broker-may-not-be-available/4512 "2022-03-21T16:02:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidleongz](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@davidleongz](https://forum.confluent.io/u/davidleongz)\
**Post date:** [21 March 2022 16:02 UTC](https://forum.confluent.io/t/connection-to-node-1-localhost-127-0-0-1-9092-could-not-be-established-broker-may-not-be-available/4512/1 "2022-03-21T16:02:01Z")

</div>

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:

> **[Why Can’t I Connect to Kafka? | Troubleshoot Connectivity](https://www.confluent.io/blog/kafka-client-cannot-connect-to-broker-on-aws-on-docker-etc/)**
>
> How to troubleshoot connectivity between Kafka clients (Python, Java, Spring, Go, etc.) to Kafka on Docker, AWS, or any other machine.

and

> [@Running Kafka Connect (Sink) On Separate Machine From Zookeeper & Topic (non localhost)](https://forum.confluent.io/t/running-kafka-connect-sink-on-separate-machine-from-zookeeper-topic-non-localhost/3038):
>
> Greetings, Beginner Problem: I’m running a Kafka environment (machine #1) on a standalone machine and MySQL on a separate machine (machine #2). The Kafka environment is running well, with an Avro(ized) topic. My goal is to use a Connector to sink the data from the topic to the MySQL database. However, when I attempt to start up the Connect instance on the database machine (#2) -pointed to the zookeeper socket of the Kafka environment (#1) -, I receive the following message: WARN [AdminClien…

and

> **[Kafka Listeners – Explained | Confluent](https://www.confluent.io/blog/kafka-listeners-explained/)**
>
> You need to set advertised.listeners (or KAFKA\_ADVERTISED\_LISTENERS if you’re using Docker images) to the external address (host/IP) so that clients can correctly connect to it. Otherwise, they’ll try to connect to the internal host address—and if...

but I don’t find the solution.

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

I set this configuration:

```auto
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!

---

<div class="post-metadata">

**Author:** ![davidleongz](https://avatars.discourse-cdn.com/v4/letter/d/a87d85/32.png) [@davidleongz](https://forum.confluent.io/u/davidleongz)\
**Post date:** [23 March 2022 08:07 UTC](https://forum.confluent.io/t/connection-to-node-1-localhost-127-0-0-1-9092-could-not-be-established-broker-may-not-be-available/4512/3 "2022-03-23T08:07:30Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [23 March 2022 09:32 UTC](https://forum.confluent.io/t/connection-to-node-1-localhost-127-0-0-1-9092-could-not-be-established-broker-may-not-be-available/4512/4 "2022-03-23T09:32:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [30 March 2022 09:32 UTC](https://forum.confluent.io/t/connection-to-node-1-localhost-127-0-0-1-9092-could-not-be-established-broker-may-not-be-available/4512/5 "2022-03-30T09:32:52Z")

</div>

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