Port 1883 (MQTT)

Port 1883 is the port of MQTT (Message Queuing Telemetry Transport), a lightweight protocol for passing messages between devices, sensors and servers…

Key facts

Port
1883
Protocols
TCP
Range
Registered port, 1024-49151
IANA service name
mqtt

IANA assigns ports in this range to services on request, under RFC 6335.

About port 1883

Port 1883 is the port of MQTT (Message Queuing Telemetry Transport), a lightweight protocol for passing messages between devices, sensors and servers, common in IoT and smart home systems. MQTT is an OASIS standard and runs over TCP.

In the IANA port registry, port 1883 is registered for the mqtt service, and port 8883 is registered for the secure-mqtt service, for MQTT encrypted with TLS. In the MQTT model, devices publish messages to topics on a central server called a broker, and other devices subscribe to topics and receive the messages.

What port 1883 is used for

  • Smart home: sensors, switches and control systems report their state and receive commands through an MQTT broker.
  • Industrial IoT: devices in the field send measurements to a central server, even over slow or unstable connections.
  • Message servers: servers such as Mosquitto accept MQTT connections, and according to the RabbitMQ documentation, RabbitMQ also accepts MQTT connections on ports 1883 and 8883 when the MQTT plugin is enabled.

Port 1883 in the firewall

Port 1883 carries messages and passwords without encryption, so allow it only from the local network or from known addresses:

  • UFW: ufw allow from 198.51.100.0/24 to any port 1883 proto tcp
  • firewalld: firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="198.51.100.0/24" port port="1883" protocol="tcp" accept'

Connect devices that come in from the internet to port 8883, with TLS:

  • UFW: ufw allow 8883/tcp
  • firewalld: firewall-cmd --permanent --add-port=8883/tcp

Risks and security

An MQTT broker passes commands to physical devices, so configure it carefully:

  • Turn off connections without a password. According to the Mosquitto documentation, when a Listener (a listening port in the configuration file) is defined, the allow_anonymous setting is off by default, and when no Listener is defined, only connections from the server itself are accepted.
  • Give each device its own username and password, and restrict it to the topics it needs.
  • Connect devices from the internet only to port 8883, with TLS.
  • Keep port 1883 open only to the local network.

Commands to check and configure

  • ss -tlnp | grep ':1883 '

    Checks that the broker is listening on port 1883, and on which address (requires root privileges).

  • mosquitto_sub -h broker.example.com -t 'sensors/#' -v -u appuser -P 'password'

    Subscribes to all topics under sensors and shows each message with its topic. The password in the command is saved in the shell history, so use it only for testing.

  • mosquitto_pub -h broker.example.com -t test/topic -m "hello" -u appuser -P 'password'

    Sends a test message to the test/topic topic.

  • mosquitto_sub -h broker.example.com -p 8883 --cafile /etc/ssl/certs/ca-certificates.crt -t 'sensors/#' -v

    Connects over TLS to port 8883 and verifies the broker's certificate against the certificate authorities trusted by the system.

  • mosquitto_passwd -c /etc/mosquitto/passwd appuser

    Creates a password file for Mosquitto with the user appuser. The -c option replaces an existing file, so to add more users, run the command without -c.

  • ufw allow from 198.51.100.0/24 to any port 1883 proto tcp

    Allows port 1883 only from the specified network (UFW).

  • firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="198.51.100.0/24" port port="1883" protocol="tcp" accept'

    Allows port 1883 in firewalld only from the specified network. Then run firewall-cmd --reload.

Port 1883 in the IANA registry

Port Protocol Service IANA registry description
1883 TCP mqtt Message Queuing Telemetry Transport Protocol
1883 UDP mqtt Message Queuing Telemetry Transport Protocol

Data source: IANA Service Name and Transport Protocol Port Number Registry (opens in a new tab)

Port 1883 FAQ

What's the difference between port 1883 and port 8883?

Both ports are used for MQTT. On port 1883 messages travel without encryption, and on port 8883 they are encrypted with TLS. On the local network you can use port 1883, and for connections from the internet use port 8883.

How do I set a password in Mosquitto?

Create a password file with mosquitto_passwd -c /etc/mosquitto/passwd appuser, and add the lines listener 1883, password_file /etc/mosquitto/passwd and allow_anonymous false to the configuration file. After a restart, only users from the file can connect.

How do I check that the broker receives messages?

Open one window with mosquitto_sub -h broker.example.com -t test/topic -v and in another window send a message with mosquitto_pub -h broker.example.com -t test/topic -m "hello". When the message appears in the first window, the broker works. When a password is required, add the -u and -P options to both commands.

Can I run an MQTT broker on a VPS?

Yes. A broker such as Mosquitto uses few resources and suits a small VPS. Set up users and passwords, open port 8883 with TLS for devices on the internet, and keep port 1883 for the local network only.

Shopping cart

Your cart is emptyYou can start with one of our popular plans.

Site search

Accessibility

Text size
100%
Accessibility statement