I use MQTT for all of the sensors in my Home Automation setup. It runs on my home server and all of my devices/sensors connect to it to publish their data. I then have software like Home Assistant or Node-RED use this data for doing automations. I also log all this data for later graphing in Grafana.

If you have never heard of MQTT think of a chatroom (like Slack or Discord) but for devices to communicate. There are channels and any client can subscribe or publish to any channel. This way you can have multiple devices communicating with each other without having to have each device know about the other devices. All it needs to know is what channels to subscribe or publish to. This is the Pub/Sub model.

Example of basic MQTT network consisting of publishers and a subscriber communicating via a broker

This post is going to cover how to install a MQTT Mosquitto broker docker container using Community Applications within Unraid.

Installing in Unraid

Installing MQTT in Unraid is actually really easy as long as we have Community Applications installed. Go to Apps and search for MQTT and install the container from user spants.

Note: You will need to install the container and have it run at least once in order for it to create all of it's config files.

MQTT container by spants in Unraid Community Applications

Configuring Authentication

You can run MQTT without authentication but having an extra layer of security is always great and highly recommended. In order to generate users and passwords for our MQTT instance we need to go to our MQTT appdata path (default location is /mnt/user/appdata/MQTT unless you changed it during install). What we need to do is add a new file called passwords.txt inside this directory that we will then add our users and what passwords we want for them like so:

password.txt example with two users

You can read the /mnt/user/appdata/MQTT/passwords.README file for more information on how to format the passwords.txt file if you are having issues (or comment below and I can help you out).

After that we need to edit the mosquitto.conf file and change the line allow_anonymous true to allow_anonymous false in order to force users to authenticate to access the server.

You now need to restart the MQTT container from the Unraid web UI and the container will encrypt the credentials and move them into the passwords.mqtt file (Do not add users directly to the passwords.mqtt file, only delete and re-order users from here). The password.txt file we created will then be deleted. Now you have your MQTT instance secured with authentication!

Testing it out

You can use the HIVEMQ Websocket Client page for testing out MQTT from your web browser. Just navigate to that link and put in your server credentials and you should be able to connect using port 9001 (this is the default unless you changed it). I use this tool all the time to test out my MQTT setup. Decent free tools are always nice :)

If you aren't able to connect then something is wrong with your setup. I recommend double checking all your container settings and checking your container logs. If you need more help figuring out a problem feel free to comment below and I will help you out the best I can.

Resource Usage

Resource usage of this MQTT server are really low. My instance is currently only using 1.785 MiB of memory and very rarely goes over 0% CPU usage. You could get away with running this on some really low-end hardware without any issues (Raspberry Pi and other devices come to mind as cheap reliable brokers). I recommend checking out Eclipse Mosquitto project's website for more information.


MQTT is amazing especially if you have a network with a lot of sensors that you need live data from (and handling of detecting if specific device is online/offline by using Last Will and Testament messages). I wish systems like Hue supported this protocol so that you didn't have to query their bridge over HTTP constantly to check for motion events and light states. I had to make a post about fixing slow Home Assistant Hue Motion sensors that wouldn't even been an issue if the bridge supported MQTT or something similar.

I use MQTT for tons of devices on my network. I have around 25 various physical sensors constantly publishing data to Home Assistant via MQTT (most are motion, temp, and door/window sensors). I also have a ton of virtual sensors created through Node-RED that also send data into Home Assistant via MQTT.

This setup has a really fast response time. I have some lights that turn on when doors open and I notice the lights turn on nearly instantly. Using MQTT has been incredibly reliable for me and I have been using it for nearly 2 years without any issues. It handles all of my automatic lights in my house, I don't really use light switches anymore.

I really like that I can have multiple systems listening for the value of a device instead of having to program that device to send to a list of specific devices over something like HTTP. I just send the data out to a channel and whatever is listening on that channel will get it. This makes wiring things together much easier and efficient.


Have any feedback? Run into any issues? Feel free to leave a comment below and I will get back to you.

Found this helpful?

If you found this post helpful please do consider donating via one of the methods below. It really helps me fund future projects that I can write about for you guys and gals. Every dollar is greatly appreciated.