MQTT ports

MQTT has two standard ports and a handful of conventions.

The standard ports

Port Transport Status
1883MQTT over TCP, unencryptedIANA registered
8883MQTT over TLS (MQTTS)IANA registered
8080, 8081MQTT over WebSocket, ws and wssConvention
9001MQTT over WebSocket, mosquitto's usual choiceConvention
443MQTT over WebSocket with TLS, or MQTT over TLS with ALPNCloud brokers, firewall traversal

Only 1883 and 8883 are fixed by the registry. Everything else is whatever the broker's listener configuration says.

Default ports by broker

Broker TCP TLS WebSocket
Mosquitto18838883 when configuredOff by default. 9001 or 8080 in most guides.
EMQX188388838083 ws, 8084 wss
HiveMQ18838883 when configured8000 when configured
AWS IoT Corenone8883, or 443 with ALPN443 wss
Azure IoT Hubnone8883443 wss
test.mosquitto.org18838883, 8884 with client certificate8080 ws, 8081 wss

Which one to use

  • On a trusted network, 1883 is fine and easiest to debug.
  • Anywhere else, 8883 with TLS. Credentials travel in the CONNECT packet, in plain text on 1883.
  • From a browser, WebSocket is the only option. Use wss on any network you do not control.
  • Through a corporate firewall, 443 with wss or ALPN is the port most likely to be open.

Check that a port is open

A quick TCP check from the command line:

nc -vz broker.example.com 1883

A quick MQTT check with the mosquitto clients:

mosquitto_sub -h broker.example.com -p 1883 -t '$SYS/broker/uptime' -C 1

Or add a connection in MQTT Viewer. A wrong port fails with connection refused, and the client logs show the handshake.

Frequently asked questions

What port does MQTT use?

1883 by default, for MQTT over TCP without encryption. MQTT over TLS uses 8883. Both are registered with IANA for MQTT.

What is the MQTTS port?

8883. MQTTS is MQTT over TLS, the same protocol inside an encrypted connection, the way HTTPS wraps HTTP.

Is port 1883 secure?

Traffic on 1883 is plain text, including the username and password in the CONNECT packet. Use 8883 with TLS on anything that leaves a trusted network.

How do you change the port in mosquitto?

Add a listener line to mosquitto.conf, for example listener 1884, and restart the broker. Add protocol websockets under a second listener line to serve WebSocket clients on another port.

Can MQTT run on port 443?

MQTT runs on 443 as MQTT over WebSocket behind TLS, or as plain MQTT over TLS with ALPN, which is how AWS IoT Core serves it. It gets MQTT through firewalls that only allow HTTPS.

More on the MQTT cheat sheet.

MQTT Viewer is free and open source, and runs on macOS, Windows and Linux.

Download MQTT Viewer