Mqtt package synology and HA in docker no connection possible

Hi there,

had to install my HA again and just used a backup-file. Nevertheless I am stuck with MQTT, I

am not able to get it connected to HA in docker.

  • I installed the MQTT package on my synology, then changed the misquitto.conf accordingly (listener 1883, allow_anonymous false, password_file /var/packages/mosquitto/var/password and created a password file (user:password) and then encrypted it.

  • At my synology port 1883 at the firewall is open

  • In HA I used the MQTT integration to connect, but always with no success…it always says:

connection failed

Any ideas what I might have missed?

It would help if you could post your Docker compose file and full MQTT conf file. As a first step, it might be worth trying with allow_anonymous true just to see if you can make a connection. That would at least narrow down the problem. Just for reference here are my Docker compose and MQTT conf files, and MQTT is running fine for me on my Synology.

version: '3'
    container_name: mqtt-server
      - '/volume1/configs/mosquitto/config:/mosquitto/config'
      - '/volume1/configs/mosquitto/data:/mosquitto/data'
      - '/volume1/configs/mosquitto/log:/mosquitto/log'
      - CONTAINER_TIMEZONE=America/New_York
      - '1883:1883'
      - '9001:9001'
    image: 'eclipse-mosquitto:latest'
    restart: unless-stopped
      - apparmor=unconfined
listener 1883
allow_anonymous true
persistence true
persistence_location /mosquitto/data/
log_dest stdout
log_dest file /mosquitto/log/mosquitto.log

@pkscout: thank you! One step foreward: I changed allow anonymus to true and now it seems to work…this would mean I made a mistake with the password file…

I created it via console:
in the conf file:
password_file /var/packages/mosquitto/var/passwd

vi passwd

and then to encrypt:
/volume1/@appstore/mosquitto/bin/mosquitto_passwd -U passwd

Am I blind?

I’m hoping someone else can help with that. One of the reasons I do MQTT with anonymous is so I don’t have to deal with the authentication stuff. I figure if someone has managed to get on my network, having MQTT authenticated isn’t really going to help me much, and all someone could really do is cause my clocks to dim and brighten. I decided that was low risk enough to not worry about it. :laughing:

I need to look up correct command but this is wrong

You do not add user or password to file. My process is

-create passed file and set file in mosquitto config to use that as password file

  • using portainer UI I connect to mosquito container using /bin/ash. You can do this from docker host command line as well
  • using below mosquito command I create user, it will prompt for password

mosquitto_passwd -c passwordfile user

Thank you both!

@TMidi: Okay, in simple words:

I go to:

cd /var/packages/mosquitto/var/

I had to create an empty file which is the basis for user and pw
example - vi passwordfile (then save it empty → ESC + :wq)
and then use your command:
mosquitto_passwd -c passwordfile user1
mosquitto_passwd -c passwordfile user2

Did I got it correct?


File creation can be done through host or container command line

Mosquito command should be inside mosquito container command line

Sorry. I check my notes and “-c” not needed

mosquitto_passwd <passwordfile> <username>

1 Like

I tested it,and it requested a password (twice). But in the file is no password or username and when I try to login with these credentials it did not work.
But I have to tell it is a synology package and not a docker container…

I got it working: It was a mix of both…

Changes mosquitto.conf

then created via: vi passfile
entered name:password --ESC :wq
then used your command:
mosquitto_passwd passfile user1

now it works