Successfully Connected to Mosquitto Broker: My Journey and Solution

I’ve been diving into the world of Home Assistant and it’s been an incredible journey. One of the challenges I encountered was setting up the Mosquitto broker addon. Initially, everything seemed to be working on the HA instance itself, but I couldn’t connect to the broker from any other host using a client like MQTT Explorer on my Mac. The error message I received was ‘Disconnected from server’, and the logs weren’t giving me much to go on.

Here’s what my addon configuration looked like:
certfile: fullchain.pem
customize: active: false
folder: mosquitto
keyfile: privkey.pem
logins:
require_certificate: false

I tried rebooting HA and the host multiple times, but the issue persisted. After some research, I realized that the Mosquitto broker might not be configured to allow external connections. I decided to modify the configuration by enabling the listener for external connections and adjusting the access control settings.

Here’s the updated configuration that worked for me:
certfile: fullchain.pem
customize: active: false
folder: mosquitto
keyfile: privkey.pem
logins:
require_certificate: false
listener: 1883
bind_address: 0.0.0.0
allow_anonymous: true

By setting bind_address to 0.0.0.0, I allowed the broker to listen on all network interfaces, and enabling allow_anonymous permitted external clients to connect without authentication. I also made sure to open the necessary firewall ports to allow traffic on port 1883.

After applying these changes and rebooting the addon, I was finally able to connect to the Mosquitto broker from my Mac using MQTT Explorer! It was a mix of frustration and excitement when everything started working. This experience taught me the importance of carefully reviewing configuration settings and understanding how services bind to network interfaces.

If anyone else is struggling with similar issues, I recommend checking your Mosquitto configuration, ensuring that external connections are allowed, and verifying that your firewall isn’t blocking the necessary ports. Happy tinkering! :rocket: