Connection failed to (internal) broker with Docker on RPi but works on Linux x86

I installed NR on RPi with Docker following the instructions on Running under Docker : Node-RED . However, it looks like the internal broker is not started: Port 1883 is not listed under sockets in state LISTEN. And NR cannot connect to the internal broker:

axel@raspi:~ $ docker run --rm -p 1880:1880 -v node_red_data:/data --name nodered nodered/node-red

> node-red-docker@1.2.9 start /usr/src/node-red
> node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"

13 Mar 12:13:39 - [info] 

Welcome to Node-RED

13 Mar 12:13:39 - [info] Node-RED version: v1.2.9
13 Mar 12:13:39 - [info] Node.js  version: v10.23.2
13 Mar 12:13:39 - [info] Linux 5.4.72-v7+ arm LE
13 Mar 12:13:42 - [info] Loading palette nodes
13 Mar 12:13:46 - [info] Settings file  : /data/settings.js
13 Mar 12:13:46 - [info] Context store  : 'default' [module=memory]
13 Mar 12:13:46 - [info] User directory : /data
13 Mar 12:13:46 - [warn] Projects disabled : editorTheme.projects.enabled=false
13 Mar 12:13:46 - [info] Flows file     : /data/flows.json
13 Mar 12:13:46 - [warn] 

Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

13 Mar 12:13:46 - [info] Starting flows
13 Mar 12:13:47 - [info] Started flows
13 Mar 12:13:47 - [info] [mqtt-broker:raspi] Connection failed to broker: mqtt://
13 Mar 12:13:47 - [info] Server now running at
13 Mar 12:14:02 - [info] [mqtt-broker:raspi] Connection failed to broker: mqtt://
13 Mar 12:14:17 - [info] [mqtt-broker:raspi] Connection failed to broker: mqtt://

When I installed NR on my Linux laptop with Docker it is LISTEN on 1883 and every works.
Therefore it looks like there is some problem with the Docker image for RPi.


Is there a specific reason you are using Docker?

IMO, for node-red it is just overkill and (as you are seeing) trips people up.

If you really want to use docker, then it is probably down to how you have configured networking.

Unless your container is sitting at IP this is not local. If the broker really is inside the node-red container, you would use mqtt://localhost:1883 or mqtt://

Lastly, what broker (and what version of that broker) are you using? Mosquitto V2+ binds to & unless you change its config, cannot be reached from other "outside" addresses.

I already have other services running in Docker, that's why I followed this path.

When NR in Docker worked straight away on my Linux laptop I somehow git the impression that there is no need for an external MQTT broker. Some months ago I played with MQTT and unknowingly still had Mosquito running on my laptop. So NR wasn't using some "internal" MQTT broker but the one I installed at that time. And this broker was obviously not available on the RPi.
After I started a Docker container with Mosquito on the RPi everything works well :slight_smile:

There has been a recent change to the mosquitto docker image so that the default is to not allow external connections so it may be that you have got the recent 2.x image on that machine.
The magic seems to be to point to a built in no-auth configuration (or configure your own of course)

docker run -itd --name mybroker eclipse-mosquitto mosquitto -c /mosquitto-no-auth.conf

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