Hi Rui I Have a problem during learning ESP8266-12E and Mqtt I use one of your code (https://randomnerdtutorials.com/esp8266-and-node-red-with-mqtt/) and change SSID, password and RPi IP address but always get this error
Attempting MQTT connection…failed, rc=-2 try again in 5 seconds
Attempting MQTT connection…failed, rc=-2 try again in 5 seconds
Attempting MQTT connection…failed, rc=-2 try again in 5 seconds
Attempting MQTT connection…failed, rc=-2 try again in 5 seconds
Hi.
That means that your ESP8266 is not able to connect to your broker.
Do you have your Raspberry Pi running the broker?
You can test the broker connection with this tutorial: https://randomnerdtutorials.com/testing-mosquitto-broker-and-client-on-raspbbery-pi/
Regards,
Sara
Great!
I’ll mark this question as resolved.
If you need further help, you just need to open a new question in our forum.
Regards,
Sara
Hi Rui,
I really enjoy your book on building an automation system under $100, but currently stuck with the MQTT broker failing to connect to my esp8266. Attempting MQTT connection…failed, rc=-2 try again in 5 seconds. I have double-checked the IP address,node-red settings for setting up the MQTT broker, and any changes that need to be made to the mosquitto config file. Does the raspberry pi os come with a firewall ?, I also have the raspberry pi Model B. Your help would be appreciated
Follow your question here: https://rntlab.com/question/esp8266-not-connecting-with-mqtt-broker-raspberry-pi/