I can't connect to MQTT server

Hi there!

My mqtt in and out nodes are always in disconnected status.

9 Nov 18:45:37 - [info] Node-RED version: v1.2.3
9 Nov 18:45:37 - [info] Node.js version: v8.10.0
9 Nov 18:45:37 - [info] Linux 4.15.0-66-generic x64 LE

My MQTT server is mosquitto, i can use it properly by command line (mosquitto_sub and mosquitto_pub) and can connect from my phone via Internet and port forwarding, using MQTT Dash app.

On starting Node-Red or deploying changes, i found some related lines like here:
9 Nov 18:48:11 - [info] Starting flows
ReferenceError: URL is not defined
at Object.connect (/usr/local/lib/node_modules/node-red/node_modules/mqtt/lib/connect/index.js:64:18)
at MQTTBrokerNode.connect (/usr/local/lib/node_modules/node-red/node_modules/@node-red/nodes/core/network/10-mqtt.js:245:40)
at MQTTBrokerNode.register (/usr/local/lib/node_modules/node-red/node_modules/@node-red/nodes/core/network/10-mqtt.js:221:22)
at new MQTTOutNode (/usr/local/lib/node_modules/node-red/node_modules/@node-red/nodes/core/network/10-mqtt.js:504:29)
at Object.createNode (/usr/local/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/util.js:493:31)
at Flow.start (/usr/local/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:194:48)
at start (/usr/local/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/index.js:345:33)
at stop.then.then (/usr/local/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/flows/index.js:210:21)
at
9 Nov 18:48:11 - [info] Started flows

My node is the next:
[{"id":"3f6184b2.17481c","type":"mqtt out","z":"6c6bad78.24ff74","name":"teszt_rohadj_meg","topic":"teszt","qos":"0","retain":"false","broker":"a1feaf13.dfb2b8","x":450,"y":260,"wires":},{"id":"a1feaf13.dfb2b8","type":"mqtt-broker","name":"MQTT_Broker","broker":"localhost","port":"1883","clientid":"nodered","usetls":false,"compatmode":true,"keepalive":"60","cleansession":false,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"ON","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"OFF","willTopic":"","willQos":"0","willRetain":"true","willPayload":"ERROR"}]

Please help me, i can't solve these issue by my own...
Thank you!

Hi, I had the same error and what helped me was updating Node.js

Please let me know if it works.

1 Like

Hi!
Many thanks! :+1:
It works fine now!

I was having the exact same issue, glad it helped you :grinning:

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