Local Mosquito broker and ESP32 does not connect

Hi All,

I would like to see sensor data using Node-red and a local MQTT (mosquito) server. I installed everything and could connect mosquito to node-red, publish and receive data.
When I use 127.0.01 and port 1883 to connect ESP32 to my local mosquito, I receive the below error:

Attempting MQTT connection...failed, rc=-2 try again in 5 seconds

I read about 20 threads on the net about the error and did every solution people suggests. However, no success up to now.

Can someone help me out?

Thank you

...........................................................................
Help us help you.

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

Please post a schematic.

Please post an image of your project.

Please describe the problem better then you just did.

......................................................................

If you are using a 9V battery like this.


Don't.

.................................................................

Info about multi things

.......................................................................................................................

I2C scanner

https://www.arduino.cc/reference/en/libraries/i2cscanner/

What did the I2C scanner report?

.........................................................................................
Bread board power rail split


...............................................................................................................................................
Serial Input basics.

................................................................................................................

search box image


.........................................................................................................

disclaimer

The events portrayed in this post are not all true. The names are not real names of real people and real organizations.
..............................................................................

Hello Idahowalker,

I think I did not cross any rules in Arduino Forum. The error I inserted in my first message is copied from my "serial monitor". Please let me know if I did something wrong.
Thanks

You need to use the external IP address (not 127.0.0.1) that Mosquitto.is listening on.

Thank you. And where i can find that external ip?

By default Mosquitto will listen on all active wired and wireless interfaces, so try one of those. A valid IP address will probably start with the numbers 192, 10, or 172 depending on how your network has been setup.

If that doesn't work then look in the mosquitto.conf file to see how the
# Listeners
section has been configured.
If it has been set to use a particular address, then use that.

Has the OP used a 3rd party application, like MQTT.fx, to successfully connect to their MQTT Broker?

Has the OP tried to use the name of the MQTT server instead of the IP address?

OP, the code?

Hi mikb55

I run a netstat through CMD and I could these IPs:
image
But non of them works.

Sorry. But what is the OP?

If you are using the latest version of Mosquitto you may be running into this problem networking - Mosquitto: Starting in local only mode - Stack Overflow

Scroll down to where it says
listener 1883

I refer to OP as the Original Poster.

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