Skip to content

EMQX TLS/SSL Connection Fails — Complete Guide

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about EMQX TLS/SSL Connection Fails. We cover key concepts, practical examples, and best practices.

The Problem

MQTTS (MQTT over TLS) connections to EMQX fail with certificate errors.

Quick Fix

Wrong

mqttx connect -h localhost -p 8883 --ssl  # Certificate verification fails
TLS handshake fails — connection rejected or certificate error.
# 1. Generate self-signed certs
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes

# 2. Configure EMQX listener
# Add to emqx.conf:
# listeners.ssl.default {
#   bind = '0.0.0.0:8883'
#   keyfile = '/etc/emqx/certs/key.pem'
#   certfile = '/etc/emqx/certs/cert.pem'
# }

# 3. Restart and test
sudo systemctl restart emqx
openssl s_client -connect localhost:8883 -CAfile cert.pem
CONNECTED with TLS handshake successful.

Prevention

Use Let's Encrypt for production certificates. Port 8883 for MQTTS, 8084 for WSS (WebSocket Secure). Enable verify_peer for mutual TLS. Check cert permissions: EMQX needs read access. Set cacertfile for client CA if using verify_peer.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### What ports use TLS?

8883 (MQTTS), 8084 (WSS). 1883 (MQTT) and 8083 (WS) are plaintext.

Can I use mutual TLS?

Yes. Set ssl_options.verify = verify_peer and ssl_options.cacertfile. Clients must present a certificate signed by the CA.

What cipher suites does EMQX support?

EMQX supports modern TLS 1.2/1.3 cipher suites. Configurable via listener.ssl.ciphers.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro