Skip to content
AdminKit

How to harden a home or small-business MQTT broker

Closing the port an MQTT broker listens on stops internet exposure, but it doesn't fix a broker that still accepts anonymous connections, has no access control between topics, and sends every message in plaintext. AdminKit explains the broker-side settings that matter once anything beyond your own machine, including other devices on the same local network, can reach it.

By AdminKit team, Netbase JSC · Updated

Key takeaways

  • Closing the broker’s port to the internet is the urgent first fix, but devices and guests on your own network can still connect.
  • Turn off anonymous access and give every device its own username and password; never share one credential across the house or office.
  • Bind the broker only to the interfaces it needs, add a topic ACL once more than a few devices share it, and use TLS on any network segment you don’t fully trust.
  • Re-check from outside after each change instead of assuming the config edit worked.

Is closing the port to the internet enough?

A port-exposure check answers one question: can something on the internet reach this broker directly. That’s the most urgent fix, but it says nothing about what happens once something on your own network — a compromised IoT device, an untrusted guest, a smart-home gadget with its own separate vulnerability — tries to connect. The OASIS MQTT 5.0 standard (see the glossary entry for MQTT for the short definition) explicitly supports authentication and recommends implementations “SHOULD offer Authentication, Authorization and secure communication options,” but it does not require a broker to enforce any of them. Most broker software ships with anonymous access enabled by default, specifically to make initial setup easier — which means the responsibility for turning that off sits entirely with whoever deploys it.

In a home or small office, the people and devices that could reach a broker fall into a few groups, and each control in this guide covers a different one:

Who can reach the brokerExampleControl that addresses it
Anyone on the internetPort 1883 forwarded on the routerRemove the port forward (step 1)
Guests and visitorsA phone on shared Wi-FiAuthentication (step 2), interface binding (step 3), TLS (step 5)
A compromised smart deviceA cheap plug with a known flawPer-device credentials (step 2), topic ACL (step 4)
Other software on the same hostA container or add-on on the same machineBind to localhost only where possible (step 3)

Step 1: What is your broker exposing right now?

Before changing configuration, know what you’re starting from. AdminKit’s MQTT exposure check tests whether a broker on your own public IP is reachable from outside your network and whether it accepts an anonymous connection — the combination that matters most, since a broker that’s reachable but requires valid credentials is a fundamentally different risk than one that accepts anyone. Port check confirms whether the broker’s port is reachable at all; confirm your current public IP first with what is my IP if you’re checking from outside your own network.

If the check shows the broker reachable from outside, the usual cause in a home or small office is a port-forward rule on the router for 1883 or 8883 — the ports IANA registers for MQTT and MQTT over TLS. Remove that rule first. If you can’t find one, check whether UPnP is enabled on the router: a device or app can open a port forward on its own through it, as our guide to mDNS, SSDP and UPnP discovery leaks explains. For remote access to home automation, a VPN into your own network keeps the broker off the public internet entirely, which is a smaller risk than any amount of broker hardening.

Step 2: How do you require a login from every device?

Disable anonymous access in the broker’s configuration and issue a distinct username and password to every device or application that connects — not one shared credential across everything. On Mosquitto, this means setting allow_anonymous false and maintaining a password file via mosquitto_passwd, as documented in the mosquitto.conf reference. A shared credential defeats the point of per-client authentication: if one device is compromised or its credential leaks, every other client sharing that password is equally exposed.

The mosquitto_passwd utility creates the file with -c, adds users without it, and removes a user with -D — useful when a device is retired or sold:

mosquitto_passwd -c /etc/mosquitto/passwd living-room-sensor
mosquitto_passwd /etc/mosquitto/passwd home-automation-hub
mosquitto_passwd -D /etc/mosquitto/passwd old-smart-plug

Keep the password file readable only by the account the broker runs as. It stores hashed passwords, not plaintext, but there is no reason for other local accounts to read it.

Step 3: Which network interfaces should the broker listen on?

Many broker installs listen on every network interface by default, which is convenient during setup but means the broker is reachable from any network segment the host touches — not just the intended LAN. Configure the broker to bind only to the interface(s) it actually needs (localhost for same-machine integrations, a specific LAN interface for local device access), rather than 0.0.0.0 by default.

In Mosquitto, the optional second value on a listener line is the address to bind to. The address below is an example; use the LAN address of your own broker host:

# only software on the same machine
listener 1883 127.0.0.1

# devices on the home LAN, through this interface only
listener 1883 192.168.1.10

After restarting the broker, a socket listing on the host confirms what it is actually bound to; 0.0.0.0:1883 in the output means every interface is still open:

$ ss -tln | grep -E ':1883|:8883'
LISTEN 0  100  127.0.0.1:1883     0.0.0.0:*
LISTEN 0  100  192.168.1.10:1883  0.0.0.0:*

Step 4: When do you need topic-level access control?

Authentication answers “who is this client.” A topic-level access control list (ACL) answers a separate question: “which topics can this specific client publish to or subscribe to once connected.” Mosquitto’s ACL file format lets you scope each authenticated user to specific topic patterns — a temperature sensor client, for example, can be restricted to publishing only on its own topic, unable to subscribe to a door-lock controller’s command topic even if it’s compromised. For a handful of trusted home devices this is a reasonable thing to defer; for an SMB deployment running many third-party integrations or IoT devices on one broker, it’s the control that keeps one compromised device from affecting everything else on the same broker.

A short ACL file is enough for most small deployments. pattern lines apply to every user, with %u replaced by the connecting username; user blocks grant extra access to one account:

# each device publishes only under its own name
pattern write home/%u/#
pattern read home/%u/set

# the home-automation hub reads and controls everything
user home-automation-hub
topic readwrite home/#

Reference the file with acl_file in mosquitto.conf. Once an ACL file is set, a user gets only the topics it grants, so test each device after enabling it.

Step 5: Do you need TLS on a home network?

Switch clients that cross any untrusted network segment (not just the internet — this includes your own Wi-Fi, if it’s shared with guests or less-trusted devices) to MQTT over TLS on port 8883 rather than plaintext 1883. TLS and authentication are independent settings: enabling one does not enable the other, and a broker can be misconfigured to accept TLS connections while still allowing anonymous logins underneath, which solves confidentiality in transit without solving who’s allowed to connect at all.

Whether TLS is worth the effort depends on the path between device and broker. A broker reached only from the same machine gains little from it. A broker reached over Wi-Fi that guests share, or from outside through a tunnel you don’t control end to end, does: without TLS, every password from step 2 crosses that network readable by anyone who can capture traffic on it. A Mosquitto TLS listener needs a CA certificate, the broker’s own certificate and its private key, per the mosquitto.conf reference:

listener 8883 192.168.1.10
cafile /etc/mosquitto/certs/ca.crt
certfile /etc/mosquitto/certs/broker.crt
keyfile /etc/mosquitto/certs/broker.key

Many small IoT devices can’t do TLS, or can’t load a custom CA. In that case keep those devices on a separate network segment with the broker, rather than leaving the whole broker on plaintext for their sake.

Step 6: How do you confirm each change worked?

Configuration changes to a broker are easy to get subtly wrong — a password file with the wrong permissions, an ACL rule that’s broader than intended, a listener still bound to the wrong interface. Re-run port check after each change to confirm the broker’s port no longer accepts unexpected connections; the MQTT exposure check adds protocol-level confirmation on top of that, rather than assuming a configuration file edit took effect correctly.

From a machine on your own LAN, two quick tests with the Mosquitto client tools confirm steps 2 and 4: an anonymous subscription should be refused, and a device account should be refused outside its own topics. Replace the address and credentials with your own:

mosquitto_sub -h 192.168.1.10 -p 1883 -t '#' -C 1 -W 5
mosquitto_sub -h 192.168.1.10 -p 1883 -u living-room-sensor -P '<password>' -t 'home/#' -C 1 -W 5

After that, keep the broker software updated through your operating system or add-on manager, and remove a device’s account the day it leaves the network. Mosquitto rereads its password and ACL files when it receives a reload signal, so removing a user doesn’t require a full restart.

MQTT isn’t the only machine protocol where “no authentication by default” is the normal, documented behavior rather than a bug — Modbus TCP, common on industrial and building-automation networks, has the same history for similar reasons. See our Modbus TCP 502 remediation playbook if your MQTT broker also bridges data from OT equipment on the same network.

Defensive use only

Every check this guide links to is for brokers and networks you own or are explicitly authorized to test. Never connect to or attempt to read from a broker you don’t control — AdminKit’s active checks only ever run against the IP making the request or an asset you’ve verified ownership of. See our Disclaimer and Acceptable Use Policy for the full terms.

This guide is general information, not a security audit of your specific network — see our disclaimer for what AdminKit's guidance does and does not commit to.

Frequently asked questions

I already closed port 1883 on my router. Isn't the broker secure now?

Closing the port stops internet exposure, which is the most urgent fix, but it doesn't change the broker's own configuration. Anyone with access to your local network — a compromised device, a guest on your Wi-Fi, a smart-home gadget with its own vulnerability — can still connect to a broker that accepts anonymous connections with no topic-level access control.

Does switching to port 8883 (MQTT over TLS) fix the authentication problem?

No — TLS on 8883 encrypts the connection so traffic can't be read in transit, but it doesn't require a username and password on its own. A broker can run TLS and still accept anonymous connections underneath it; encryption and authentication are separate settings that both need to be configured.

What's the minimum broker-side configuration for a home setup?

Disable anonymous access, create a username and password for each client that needs to connect, and bind the broker to listen only on the interfaces it actually needs (localhost or your LAN interface, not every interface by default). That combination closes the two most common gaps without requiring a full access-control-list setup.

What are topic-level ACLs, and do I need them for a home setup?

An access control list restricts which topics a given authenticated client can publish or subscribe to, so a compromised sensor client can't also read or spoof messages meant for your door-lock controller. For a small home setup with a handful of trusted devices this is a nice-to-have; for an SMB deployment with many third-party or less-trusted devices on the same broker, it's a meaningful barrier against one compromised device affecting everything else.

How do I check whether my broker is currently exposed before I start hardening it?

AdminKit's MQTT exposure check (/tools/mqtt-check/) sends one anonymous CONNECT to the public IP you're connecting from and reads the broker's CONNACK, so it tells you whether the broker responds from outside your network and whether it accepts an anonymous connection — whether you're starting from 'reachable and open' or 'reachable but already requiring credentials.' Port-check confirms whether the broker's port is reachable at all.

Want AdminKit to watch this for you?

Free checks tell you the state today. Protective DNS and monitoring tell you when it changes.

Huy Nguyen (David), Founder and CEO of Netbase JSC

Talk to an expert

Huy Nguyen (David), Founder & CEO, Netbase JSC

Ask whether this fix applies to your setup, or get a second pair of eyes on your DNS and mail records.