# Need Help with MQTT over MQTTS on My VPS - Node-RED Failing to Connect to Broker

**URL:** <https://discourse.nodered.org/t/need-help-with-mqtt-over-mqtts-on-my-vps-node-red-failing-to-connect-to-broker/90459>\
**Category:** General\
**Created:** [26 August 2024 21:59 UTC](https://discourse.nodered.org/t/need-help-with-mqtt-over-mqtts-on-my-vps-node-red-failing-to-connect-to-broker/90459 "2024-08-26T21:59:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kdiot](https://avatars.discourse-cdn.com/v4/letter/k/b38774/32.png) [@kdiot](https://discourse.nodered.org/u/kdiot)\
**Post date:** [26 August 2024 21:59 UTC](https://discourse.nodered.org/t/need-help-with-mqtt-over-mqtts-on-my-vps-node-red-failing-to-connect-to-broker/90459/1 "2024-08-26T21:59:19Z")

</div>

I’m running into an issue with my MQTT setup over MQTTS and hoping to get some help from the community. Here’s a detailed breakdown of my setup and what I’ve tried so far.

My Setup:

VPS Details:

I'm running a VPS with Ubuntu.

Node-RED is installed and running as the root user with user authentication over https:// .

Certificates:

I’ve generated my own certificates using OpenSSL: CA.crt, CA.key, server.crt, and server.key. and another server certificate and key for my node-red to connect over https using the same CA.crt. and installed it on m browser and it has been accepted also.

These certificates have been properly tested using openssl s\_client and everything seems to work when I check the CA using:

`openssl s_client -connect my-VPS-IP:8883 -CAfile CA.pem`

The connection is established successfully, and verification returns OK also I used moquitto\_client sub and pub using --CA option also was OK.

Node-RED Configuration:

I have an MQTT broker setup over MQTTS at mqtts://my-VPS-IP:8883.

The broker works fine when I uncheck the "Verify Server Certificate" option in Node-RED's MQTT node.

But as soon as I check the box to verify the certificate and provide the CA.pem, the connection fails with repeated logs showing:

`Connection failed to broker: plc@mqtts://my-VPS-IP:8883`

The certificates are properly placed and accessible by Node-RED, running under the root user.

Node-RED Logs:

The logs show repeated failures when trying to connect to the broker:

`sudo journalctl -u node-red -f`

Example log:

less

` Aug 26 10:46:29 - [info] [mqtt-broker:MQTT broker] Connection failed to broker: plc@mqtts://my-VPS-IP:8883`

TLS Compatibility:

I’ve confirmed that the broker supports TLSv1.3 (checked via openssl).

Node.js version used by Node-RED also supports TLS 1.2 and 1.3.

The Issue:

Node-RED connects fine when I disable the server certificate verification.

When I enable certificate verification in the MQTT node and provide the CA.pem, the connection fails repeatedly.

The certificates work fine when tested with openssl, but Node-RED seems to have issues verifying the broker's certificate.

What I’ve Tried:

Tested the Broker with OpenSSL:

Works fine, and certificate verification passes.

Verified the File Path:

The CA.pem file is correctly referenced in Node-RED's MQTT node configuration.

Permissions on the CA.pem file are correct (readable by Node-RED).

Checked TLS Version Compatibility:

The broker and Node.js (Node-RED) both support TLSv1.3, and no version mismatch seems to be the issue.

Any Ideas?

If anyone has experience with this kind of setup or has seen similar issues with Node-RED and MQTT over MQTTS, I would greatly appreciate your insights. I feel like it’s either a small configuration error or something specific with how Node-RED handles certificates, but I can't pinpoint it.

Thanks in advance for any help!

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 August 2024 22:06 UTC](https://discourse.nodered.org/t/need-help-with-mqtt-over-mqtts-on-my-vps-node-red-failing-to-connect-to-broker/90459/2 "2024-08-26T22:06:34Z")

</div>

Have you tried a different MQTT client (to rule out certs and connectivity) from the server running node-red to the MQTT broker server? [Mosquito pub](https://mosquitto.org/man/mosquitto_pub-1.html) supports TLS

---

<div class="post-metadata">

**Author:** ![kdiot](https://avatars.discourse-cdn.com/v4/letter/k/b38774/32.png) [@kdiot](https://discourse.nodered.org/u/kdiot)\
**Post date:** [26 August 2024 22:08 UTC](https://discourse.nodered.org/t/need-help-with-mqtt-over-mqtts-on-my-vps-node-red-failing-to-connect-to-broker/90459/3 "2024-08-26T22:08:26Z")

</div>

Yes, and it connects with no problem at all.

 ![Capture2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/b/1b0d1889df63eb9ab693a042c355fdacfbfb98d2.png)

---

<div class="post-metadata">

**Author:** ![kdiot](https://avatars.discourse-cdn.com/v4/letter/k/b38774/32.png) [@kdiot](https://discourse.nodered.org/u/kdiot)\
**Post date:** [26 August 2024 23:11 UTC](https://discourse.nodered.org/t/need-help-with-mqtt-over-mqtts-on-my-vps-node-red-failing-to-connect-to-broker/90459/4 "2024-08-26T23:11:03Z")

</div>

I noticed error message in my browser console every time I change the status of "verify server certificate" check-box and click upload the error message appears "oneditsave 40a7f8e85e10c212 tls-config ReferenceError: clearNameData is not defined."

 ![Capture](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/b/eb1dad87c293acf291a79430cbca126367a45f42.jpeg)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 November 2024 23:11 UTC](https://discourse.nodered.org/t/need-help-with-mqtt-over-mqtts-on-my-vps-node-red-failing-to-connect-to-broker/90459/5 "2024-11-24T23:11:55Z")

</div>

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