How to connect node-red with mqtt broker

I have corrected the flow formatting. You should have used the </> button at the top of the forum entry window. In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote ```) . The </> button provides those

   code goes here 

See this post for more details - How to share code or flow json

Is that the same broker and port that you have used successfully in mqtt explorer?

That does not look like a valid topic.

I'm confused... in reply to the question asked above by @jbudd you said... 'local machine'.
Now you are showing a reference to
Where is the MQTT broker - local or remote?

If you are using the test-server at Eclipse, then try this very simple flow and see if it works for you.



[{"id":"a4261bec1cbf0778","type":"tab","label":"Flow 39","disabled":false,"info":"","env":[]},{"id":"1678825c5d940452","type":"mqtt in","z":"a4261bec1cbf0778","name":"","topic":"test","qos":"2","datatype":"auto-detect","broker":"2d2f5234db1e57bd","nl":false,"rap":true,"rh":0,"inputs":0,"x":150,"y":220,"wires":[["9ef778879f8ca7c5"]]},{"id":"981d13a9a47220e3","type":"mqtt out","z":"a4261bec1cbf0778","name":"","topic":"test","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"2d2f5234db1e57bd","x":330,"y":140,"wires":[]},{"id":"e553550126382b67","type":"inject","z":"a4261bec1cbf0778","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello World","payloadType":"str","x":170,"y":140,"wires":[["981d13a9a47220e3"]]},{"id":"9ef778879f8ca7c5","type":"debug","z":"a4261bec1cbf0778","name":"repsonse","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":340,"y":220,"wires":[]},{"id":"2d2f5234db1e57bd","type":"mqtt-broker","name":"Eclipse","broker":"","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willRetain":"false","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""}]

As this is a test-broker, anyone can publish and subscribe to it (see example below).

You will probably want to think about this issue and maybe organise a private-broker for your project.

I blame myself. I should have asked the questions like this

  1. What is the name of the MQTT broker you are using?
  2. Is it in the cloud (eg hivemq), or on a local machine (eg Mosquitto)?
  3. If the MQTT broker is on a local machine, what is it's IP address (eg
  4. What is the local IP address of your Node-red machine (eg

I wanted to know if Node-red and MQTT broker are installed on the same machine because there are extra setup steps for the broker if it's on a different machine.

Note that "localhost" doesn't tell us anything useful regarding MQTT, though it does indicate that you access Node-red from a browser on the same machine it's installed on.

1 Like

i have created these nodes, when i deploying these nodes, it was showing connecting but it's not connecting, can you help me why it is not connecting.

Have you successfully connected to the broker using MQTTExplorer?

Also, that subscription topic is invalid and will likely cause any broker to disconnect the client (in this case, the client is your node-red MQTT nodes)

As @Steve-Mcl said, your topic is invalid. I suggest you go to this link and read about MQTT topics.

yes, i connected to the broker using MQTTExplorer.

Note that I pointed out on October 20 that you were trying to use an invalid topic.

A while ago you showed us this to demonstrate that you were using the Eclipse broker.

Now you show us this
I can find no reference to a public MQTT service at InfyOm Technologies.
I am dubious about the first part of each server's URL being the same and the port number being different but similar.

In short, you are unable to connect because the URL or the port number or the security credentials in your MQTT broker config node are wrong. Or just possibly, because your machine does not have free access to the internet due to a corporate proxy server.

Since we know almost nothing about your setup and you keep changing without explanation the information you give us, it is IMPOSSIBLE TO HELP YOU.

Incidentally I tried mqtt topics such as test///test and test///test/# using Mosquitto. It did not complain, but repeated / characters are not ignored (as they would be in a Linus pathname for instance)

i connected my local mqtt broker with Node-red iot simulator, i have a doubt that, here i'm sending command & control messages through postman to Node-red simulator.
is it possible to recieve the command & control messages in the Node-red using postman.
can you tell me how to see server logs on Node-red simulator.

Did you ever try out the test flow I posted above (item 23 in this thread) that uses the Eclipse test-server??

MQTT nodes come as part of the core installation. Please dont instruct the user to install non core MQTT nodes without good reason.

I hope you dont mind me asking was this written by an AI bot for you? It looks suspiciously like a ChatGPT / Bard / AI generated response.

yes, i tried.

i was getting missing broker configuration, how to provide broker configuration in the node-red simulator.
i'm able to send command & control messages sent successfully through postman, but i'm not getting anything in the node-red simulator.

The debug message shows you which node issued the error message.
Is your node ThingsUniverse related to MQTT?

You are using the Node-red editor.
There is no such thing as a Node-red simulator.

You already know how to configure the mqtt broker in Node-red.
The status of your mqtt-in showing "Connected" proves that it is correctly set up and working.

Do you still have the flow which tests your mqtt setup?

can you provide me mqtt and test nodes (server, topic, connection and security) details.

i was getting like disconnected when i hit test:Hello.

in the mqtt out node, it was showing invalid topic