Node red fails to connect to mqtt broker

I have Mosquitto on RPI 3b that I used for couple of years now and did not do any changes in setting. RPI has restarted after power outage and gives me following error message when starting Node Red-

23 May 15:37:06 - [info] Starting flows
23 May 15:37:07 - [info] Started flows
23 May 15:37:07 - [info] [mqtt-broker:178b2db4.4b9292] Connection failed to broker: mqtt://192.169.1.29:1883
23 May 15:37:07 - [info] [mqtt-broker:83ee96b6.cd6988] Connected to broker: mqtt://localhost:1883
23 May 15:37:07 - [info] [mqtt-broker:378b7afe.ff3bc6] Connected to broker: mqtt://localhost:1883
23 May 15:37:07 - [info] [mqtt-broker:b4426f3a.947b8] Connected to broker: mqtt://192.168.1.30:1883

Why does it fail and how can I fix it? Interesting that it connects to localhost, which is 192.168.1.29 in my case... but fails to connect directly to mqtt://192.169.1.29:1883

Have you got three separate mqtt broker nodes all pointing to the same broker? Two with localhost and one with the ip address? You should delete two of them and just use one.

What version of mosquitto are you using? V2.x requires access via ip address to be enabled in the config.
sudo apt policy mosquitto

Not sure how can I delete nodes.

Here is output about mosquitto version:
mosquitto:
Installed: 1.4.10-3+deb9u4
Candidate: 1.4.10-3+deb9u4
Version table:
*** 1.4.10-3+deb9u4 500
500 http://mirrordirector.raspbian.org/raspbian stretch/main armhf Packages
100 /var/lib/dpkg/status

Go to the Menu dropdown > Configuration Nodes from where you can click and hit delete key for two of them. When you deploy that the MQTT nodes using the deleted ones will show the red triangle and you can open them and select the remaining broker node.

You are using v1.4 so that doesn't explain the lack of connection. Are you certain the you have the right ip address? Check using
ip addr

I do run Mosquitto on Raspberry Pi 3B, do not have Configuration Nodes on main RPI menu.
I checked IP and it is correct:

3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:b5:74:b6 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.29/24 brd 192.168.1.255 scope global wlan0
valid_lft forever preferred_lft forever
inet6 fe80::547b:b5aa:d763:864/64 scope link
valid_lft forever preferred_lft forever

Please post the full node red startup log so we can see more about your environment.

That should be 168!

Wow, I am blind apparently, you are absolutely right.

How do I delete unnecessary nodes. My Mosquitto is running on Raspberry Pi 3B and I thought I have only command line option to adjust something on Mosquitto, do not have any front end application.

Here is complete startup log:

Start Node-RED

Once Node-RED has started, point a browser at http://192.168.1.29:1880
On Pi Node-RED works better with the Firefox or Chrome browser

Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot

To find more nodes and example flows - go to http://flows.nodered.org

Starting as a systemd service.
Started Node-RED graphical event wiring tool..
23 May 15:36:56 - [info]
Welcome to Node-RED

23 May 15:36:56 - [info] Node-RED version: v0.17.4
23 May 15:36:56 - [info] Node.js version: v4.8.2
23 May 15:36:56 - [info] Linux 4.19.66-v7+ arm LE
23 May 15:36:57 - [info] Loading palette nodes
23 May 15:37:02 - [info] Dashboard version 2.7.0 started at /ui
23 May 15:37:05 - [warn] ------------------------------------------------------
23 May 15:37:05 - [warn] [moment] SyntaxError: Unexpected token = (line:23)
23 May 15:37:05 - [warn] ------------------------------------------------------
23 May 15:37:05 - [info] Settings file : /home/pi/.node-red/settings.js
23 May 15:37:05 - [info] User directory : /home/pi/.node-red
23 May 15:37:05 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
23 May 15:37:05 - [info] Server now running at http://127.0.0.1:7360/
23 May 15:37:06 - [info] Starting flows
23 May 15:37:07 - [info] Started flows
23 May 15:37:07 - [info] [mqtt-broker:178b2db4.4b9292] Connection failed to broker: mqtt://192.169.1.29:1883
23 May 15:37:07 - [info] [mqtt-broker:83ee96b6.cd6988] Connected to broker: mqtt://localhost:1883
23 May 15:37:07 - [info] [mqtt-broker:378b7afe.ff3bc6] Connected to broker: mqtt://localhost:1883
23 May 15:37:07 - [info] [mqtt-broker:b4426f3a.947b8] Connected to broker: mqtt://192.168.1.30:1883
23 May 15:37:22 - [info] [mqtt-broker:178b2db4.4b9292] Connection failed to broker: mqtt://192.169.1.29:1883
23 May 15:37:37 - [info] [mqtt-broker:178b2db4.4b9292] Connection failed to broker: mqtt://192.169.1.29:1883

You are using an ancient version of node red (0.17.4, current version is 1.3.5), and a very old version of nodejs (4.8.2, the current node red requires at least 8.x, but the recommended version is 12 or 14). I don't know how to delete config nodes on that version.
If this is a stable system and you are not planning any more development with it then you can stick with what you have, as it is working, but if you plan further development then I suggest upgrading everything using the recommended upgrade script. That will upgrade node-red and nodejs. Back up anything vital on the pi first. I presume you have already backed up the flows file (which is referenced in the log you posted). Back up everything in that folder except the node_modules folder which is huge and can be rebuilt anyway. Or even better an image backup of the SD card of course.

1 Like

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