Troubleshooting
Node-RED MQTT fails when the broker rejects plain MQTT
Short answer
The connect fails because the MQTT OUT broker configuration sends plain MQTT while the Mosquitto listener accepts TLS only; the address and port can be correct and it still fails. Confirm which side is at fault with MQTT Explorer, then pick one mode on both ends — enable the plain listener you intend, or enable TLS in the client — and verify with a same-topic publish and subscribe.
On this page
- Why does Node-RED MQTT fail when the address and port are correct?
- How do I test the broker without Node-RED in the path?
- Which client and listener pairings connect, and which fail?
- What if MQTT Explorer cannot connect either?
- How do I allow plain MQTT on the Mosquitto broker?
- How do I turn on TLS in Node-RED instead?
- How do I verify the connection carries data?
- Questions asked
Node-RED's MQTT OUT node fails to connect because it is sending plain MQTT to a Mosquitto listener that accepts TLS only — the address and port can be exactly right and the connect still fails. Confirm which side is at fault with a second client such as MQTT Explorer pointed at the same endpoint, then make both ends use one mode: enable the plain listener you actually intend, or enable TLS in the MQTT broker configuration node. This article walks the fault in the order you meet it: client test, mode matrix, both fixes, and an end-to-end verification with counted messages.
Why does Node-RED MQTT fail when the address and port are correct? #
Because connection mode is a separate gate from reachability: a Mosquitto listener that requires TLS closes a plain MQTT CONNECT immediately, so Node-RED shows a connect failure on an endpoint a ping and a browser would call healthy. The MQTT OUT node's broker configuration holds three things that must agree with the listener: server address, port, and whether TLS is enabled — the node documentation describes that switch as enabling TLS for encrypted connections. On the broker side, each Mosquitto listener enforces its own mode and neither side negotiates down, so crossed modes fail even on a correct endpoint, with the same connecting/disconnected status cycle a wrong password produces.
When TCP clearly reaches the broker but the MQTT CONNECT never completes, diagnosing an MQTT connect that fails while TCP works narrows the protocol-level causes; the encryption-mode mismatch covered here is one of them.
How do I test the broker without Node-RED in the path? #
Point MQTT Explorer, or any second desktop client, at the same address and port Node-RED uses, with TLS off, and read its status: that one result separates broker-side from client-side causes in under a minute. Run the test deliberately:
- Copy the server address and port out of the MQTT OUT broker configuration exactly, not from memory.
- Set TLS off and leave credentials empty for the first attempt.
- Connect and record which result you get: connected, refused, opens then closes, or timeout.
- Repeat with TLS on, pointed at the broker's TLS port, 8883 by convention.
- Subscribe to the exact topic string the flow publishes.
Read the result literally. Refused means nothing is listening on that port. Opens-then-closes means a listener exists but rejected what arrived — the signature of a mode mismatch. Timeout means the packets never arrived, which is routing or a firewall rule, not MQTT.
Which client and listener pairings connect, and which fail? #
Two of the four mode pairings connect — plain to plain and TLS to TLS — and the two crossed pairings fail in different, recognizable ways, which is what makes this fault identifiable from the client side. The full decision matrix:
| Client (MQTT OUT config) | Broker listener | What you observe | Decision |
|---|---|---|---|
| TLS off | Plain allowed | Connect completes | Mode is not your fault; check credentials and topics |
| TLS off | Plain disabled, TLS required | TCP opens, then the broker closes the connection during the handshake | Enable the plain listener or turn TLS on in the client |
| TLS on | Plain only | Handshake fails; the broker sees TLS bytes on a plain port and drops them | Point the client at the TLS listener |
| TLS on | TLS configured | Connect completes once the certificate is trusted | If it still fails, fix CA trust, not the mode |
Worked example with illustrative values. Broker at 192.168.10.24 runs a TLS listener on 8883 and no plain listener. Node-RED MQTT OUT is set to server 192.168.10.24, port 1883, TLS off, and the node status cycles. MQTT Explorer with TLS off on 1883 is refused, because no listener owns that port; MQTT Explorer with TLS on against 8883 connects. Two of the four pairings tested with one tool, and the fault is pinned to the client's port-and-mode pair. On broker packages that expose a single port with an explicit enable for unencrypted connections, both attempts land on one port: TLS off fails, TLS on connects, and that setting is the fault. The decision for the TLS-only broker: put TLS on the client and keep one mode plant-wide rather than opening a second one.
What if MQTT Explorer cannot connect either? #
Then the fault sits below MQTT: with no configuration file a Mosquitto broker listens on port 1883 on the loopback interface only, so no other host can reach it at all until you give it a listener. That default is documented in the Mosquitto manual, and it has a clean signature — a client on the broker's own host connects to 127.0.0.1:1883 while every remote client fails. Run the broker with a configuration file that defines the listener you intend, and allow that port inbound on the host firewall. If the remote symptom is a timeout rather than a refusal, look at routing and filtering before touching MQTT at all.
How do I allow plain MQTT on the Mosquitto broker? #
Define a listener that serves plain MQTT — port 1883 — in the broker's configuration file, or, on a broker app with an explicit enable for unencrypted connections, switch that setting on, then restart the broker. Mosquitto runs plain and TLS listeners side by side on separate ports, so enabling plain access leaves the TLS path and its certificates untouched. Plain MQTT carries usernames, passwords and payloads unencrypted, so enable it only on the segment you have deliberately decided may carry that traffic, never as a workaround for a client nobody reconfigured. The commitment: traffic that stays inside an isolated controls VLAN can justify plain on 1883; any path that crosses a routed network gets TLS and a corrected client.
How do I turn on TLS in Node-RED instead? #
Open the MQTT OUT node's broker configuration, enable the TLS option the node documentation describes as enabling TLS for encrypted connections, point it at the TLS port, 8883 by convention, and supply the CA certificate the broker's certificate chains to. Steps:
- In the MQTT OUT node, open the broker configuration beside the server field.
- Enable the TLS option and create the TLS configuration it links to.
- Load the CA certificate; add a client certificate and key only if the listener requires mutual TLS.
- Set the port to the TLS listener's port.
- Deploy and read the node status — connected means the transport matched.
If the handshake still fails with TLS on, the cause is almost always certificate trust rather than the broker; work the pair safely first by running a secure Mosquitto lab broker with Node-RED and copying the proven settings across.
How do I verify the connection carries data? #
Publish from Node-RED on the exact topic string the flow uses and subscribe to that same topic in MQTT Explorer: a zero received count on a healthy connection means the topic strings differ. Wire an inject node to MQTT OUT repeating every 1 second and let it run 60 seconds: 1 message per second × 60 seconds = 60 publishes. MQTT Explorer subscribed to the identical topic must show 60 received, and 60 of 60 proves the path from flow to broker to external subscriber. Then reverse it: publish one message from Explorer and watch the flow's MQTT IN debug output. If the connection is healthy but the flow still shows nothing, the fault is data-side — missing MQTT sensor data in Node-RED covers that branch — not the connection you just fixed.
Questions asked
Can Mosquitto serve plain MQTT and TLS at the same time?
Yes. Mosquitto runs separate listeners, so a plain listener on 1883 and a TLS listener on 8883 can coexist on the same broker, and each enforces its own mode. That is the usual way to keep legacy local clients working while new paths use TLS.
Does a successful MQTT Explorer connection prove my Node-RED settings are right?
No. It proves Explorer's own address, port, mode and credentials work against that broker. Explorer also keeps saved connection profiles, so confirm the profile you loaded has TLS off or on as intended before comparing it field by field with the MQTT OUT broker configuration.
Will enabling plain MQTT affect clients already connected with TLS?
No. Adding a plain listener leaves the TLS listener and its certificates untouched; existing TLS clients reconnect exactly as before. What changes is exposure: any host that can route to the new port can now send unencrypted MQTT to it.
Should I fix the username and password before the connection mode?
No. Credentials travel inside the MQTT CONNECT packet, which is only delivered after the transport matches the listener. A plain CONNECT reaching a TLS listener is closed before authentication is ever evaluated, so correcting the password first cannot help.
Why can no other computer reach a freshly installed Mosquitto broker?
Because the documented default, with no configuration file given, is a single listener on 1883 bound to the loopback interface. Test from the broker's own host against 127.0.0.1:1883: if that connects while a remote client fails, the loopback bind is confirmed and a configuration file defining a listener is the fix.