I have been banging my head off the wall trying to get Mosquitto/MQTT set up on my HA. Using HA 0.84.6 in Docker and using docker-compose on a NUC if that matters at all.
Here’s my docker-compose portion of the file for MQTT:
I’m positive that it will be obvious to most people, but I can’t seem to figure out what I’m doing wrong. I have attempted to connect to the server using MQTT.fx and it also doesn’t show up in the list of available services in the HA side bar. I have changed the broker to the IP address of my HA machine as well.
I have tried to follow the instructions here, but I’m not getting any farther. Can anyone help show me what I’m doing wrong?
What does the logfile say? Do you set a username/password anywhere? (for the broker)?
I am using hass.io with the MQTT add-on, not docker-compose
(Also, this topic is hidden because you didn’t set a category for it)
I use the docker setup similar to you.
The IP address should be the IP of the docker host, I don’t think localhost will work, as that is inside the docker container.(afaik) or if your mqtt docker has it’s own IP then use that.
My config is here, but not very useful as everything is in the secrets file…
Hi, I don’t think you should use ports - "1883:1883" - "9001:9001" in combination with network_mode: host. Use either one or the other. I use the first one.
Do you have a config file called /srv/docker/mosquitto/config/mosquito.conf ?
eclipse-mosquitto expects a config file. You can use an empty one.
To get the default mosquito.conf, you can first run eclipse-mosquitto without volume mounts and then executed this to export the file:
Success! There appeared to be an issue with the mosquitto.conf. I kept getting a permission denied error trying to do @tedsluis suggestion, but I just went to the github page and copied/pasted the default .conf file into my setup and then restarted the docker container.
I removed the network_mode: host as suggested and instead included the ports. Finally, I modified the configuration.yaml file to point to the device’s IP address rather than localhost or 127.0.0.1.
Thanks so much to everyone for the quick and great help!
Sure, I don’t think I ever changed anything here.
I run on unRAID using the container and template by spants spants/mqtt:latest
root@Tower:/mnt/cache/appdata/MQTT# cat mosquitto.conf
# Place your local configuration in /config/conf.d/
retry_interval 20
sys_interval 10
store_clean_interval 10
user mosquitto
max_inflight_messages 40
max_queued_messages 200
queue_qos0_messages false
message_size_limit 0
allow_zero_length_clientid true
persistent_client_expiration 3m
allow_duplicate_messages false
autosave_interval 60
autosave_on_changes false
persistence false
persistence_file mosquitto.db
persistence_location /config/data/
# Port to use for the default listener.
listener 1883
listener 9001
protocol websockets
log_dest stderr
log_type all
connection_messages true
log_timestamp true
include_dir /config/conf.d
# If the password.mqtt file is empty, this has no effect.
allow_anonymous true
# DO NOT CHANGE THIS LINE BELOW!!!
password_file /config/passwords.mqtt