Can't connect to Mosquitto MQTT broker running on my localhost 1883

Currently I'm running Node-RED using docker on my local system with "docker run -it -p 1880:1880 -v D:/ABOS/Node-RED/data:/data --name local-node-red nodered/node-red" command and it executed successfully and also I can open node-RED on http://localhost:1880/.

I have also started Mosquitto MQTT broker with default setting on my local system on port 1883.
I tried to subscribe and publish message to this broker using mosquitto commands and it works perfectly.

Now when I try to connect to that Mosquitto Broker using MQTT In and MQTT Out node , those node can't connect to that broker.
I'm attaching Mqtt Nodes configuration and error that I get in node-RED.

Please help me to connect to that mosquitto mqtt broker running on my localhost.

It is important to understand that when an application runs in a container it gets its own TCP/IP stack.

That means that will point to that dedicated stack inside the container, not the host machine.

Docker sets up a virtual network that all containers and the host live on. By default the host address will be

(You will need to also ensure that mosquitto is set up to allow connections on addresses other than by adding a new listener and probably allowing anonymous connections)

If the broker is on the host machine you may just need to open that port on your container by adding -p 1883:1883 to your launch command

Err no, that worked only be if the broker is in another container...

Depends if the docker runs as bridge or host. I assume, that it is in bridge. then you have to do portforwarding. You can also try to run it as host, then it whould work with youre settings.

You must connect host ip!!! 192.168.XXX
not (container ip)

1 Like

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