S-SCOTTEK← HomepageNewsGuidesBuyingTeamForumSupportlog in · sign up
self-hosting 2026-11-15

Install Mosquitto MQTT Broker on Ubuntu (Password-Locked)

What the video covers

The video walks through installing the Eclipse Mosquitto MQTT broker on Ubuntu 24.04 from the Ubuntu archive, confirming the broker answers with version 2.0.18, sending a first test message, then adding a password file and a short config so anonymous clients are refused. This companion guide gives you the same path in copyable form with expected results after each step, plus troubleshooting and cleanup. Watch it alongside the video at Install Mosquitto MQTT Broker on Ubuntu (Password-Locked).

MQTT is the message backbone of many self-hosted smart-home setups, carrying readings and commands between gear like Home Assistant, Zigbee2MQTT, Node-RED, and ESPHome devices. A broker with no password accepts publishes from anyone who can reach it, so the password lock in this guide is the part that matters most.

Prerequisites

Prerequisites card from the video: 64-bit Ubuntu 24.04 with internet, a sudo account, about 5 MB free disk, and port 1883 free, with SUDO, 5 MB, and PORT 1883 badges
Prerequisites card from the video: 64-bit Ubuntu 24.04 with internet, a sudo account, about 5 MB free disk, and port 1883 free, with SUDO, 5 MB, and PORT 1883 badges (Still from the walkthrough video.)

Install the broker and clients

The video installs both the broker and the command-line clients from Ubuntu's own archive, so there are no third-party repos or signing keys to add. Untested: the apt install and systemctl steps below follow the official documentation and the video but were not exercised in this guide's sandbox, which lacked root access.

Simulated terminal frame from the video enabling and verifying the broker: systemctl enable now, is-active returning active, and mosquitto version 2.0.18 answering
Simulated terminal frame from the video enabling and verifying the broker: systemctl enable now, is-active returning active, and mosquitto version 2.0.18 answering (Still from the walkthrough video.)

If the service is not active, run sudo systemctl status mosquitto and sudo journalctl -u mosquitto --no-pager | tail -20 to see why. A common cause is something already holding port 1883, which you can check with ss -tlnp | grep 1883.

Lock it with a password

A fresh Mosquitto install accepts anonymous local clients, which is why the video moves straight to a password file plus a three-line config file. The config options used here are documented in the mosquitto.conf man page and the password tool in the mosquitto_passwd man page.

Simulated terminal frame from the video setting the password lock: mosquitto_passwd creating the pilot user, the three-line secured.conf, and the service restart
Simulated terminal frame from the video setting the password lock: mosquitto_passwd creating the pilot user, the three-line secured.conf, and the service restart (Still from the walkthrough video.)

If the broker fails to restart after the config change, recheck the three lines for typos and confirm the password file path exists with ls -l /etc/mosquitto/passwd. Permission errors usually mean the file was created somewhere the mosquitto service user cannot read.

Prove the lock with a live roundtrip

The video proves the setup with a publish and subscribe roundtrip on topic homelab/test, first open and then locked. This companion guide follows that same check so you know the broker routes messages and the password gate works.

If the authed roundtrip fails, the usual suspects are a wrong password, quoting around a password with special shell characters, or testing against the wrong port. If anonymous clients still get through, confirm allow_anonymous false is spelled exactly and that you restarted the service after writing the file. Source and further options are on GitHub.

Rollback and cleanup

Watch the walkthrough

Watch on YouTube