I spent a lot of time fighting these errors when trying to connect via MQTT: Connection Refused: not authorised. client disconnected not authorised
The instructions on the Home Assistant Add-on: Mosquitto broker documentation tab state:
Create a new user for MQTT via your Home Assistant’s frontend Settings → People → Users , (i.e. not on Mosquitto’s Configuration tab). Notes:
This name cannot be homeassistant or addons, those are reserved usernames.
I could not get it to work as documented. Instead, I had to create a “People” account, not a “Users” account… ie. Settings → People → People
On top of that, the documentation for People (under the link “Learn more about people” talks about these kinds of accounts being used for GPS trackers. It makes no mention of MQTT.
Did I completely mess up, or is the documentation wildly inaccurate? Plus, why would it matter? What’s the difference between a People and a User?
Further down in the documentation it mentions having to manually create and edit some configuration files:
/share/mosquitto/acl.conf
/share/mosquitto/accesscontrollist
And adding the “User” you created to those files. I did this and when I created a user as documented via Settings → People → Users , it worked.
But… why? Why do all of those extra steps if simply creating a “People” will work?
I had this exact same problem.
I had 3 devices and mqtt explorer working just fine.
I was connecting a new device (my own code) to the broker and I kept getting connection refused errors (5) using the same HA user account and pwd.
For the heck of it I created a new user account and pwd and all of a sudden it worked. The new pwd was much simpler( only 5 lower case letters) since I did not think it would work. I will debug and figure what happened, howeve you may try this.
I got it working mqtt with Mosquitto addon on HAOS.
* Core2024.11.1
* Supervisor2024.11.2
* Operating System13.2
Steps:
via Settings/people/users: create the user used for Mqtt with password - local login only - eg my-mqtt-user
with the Add-on “Terminal & SSH” create the directory /share/mosquitto
create two files in this:
3.1 /share/mosquitto/acl.conf
content:
This is the access control list file for Mosquitto
it points to the accesscontrollist file below
acl_file /share/mosquitto/accesscontrollist
3.2 /share/mosquitto/accesscontrollist
content:
# Allow a specific user to publish and subscribe to all topics
# put_here_your_mqtt user you use eg in shellies
user my-mqtt-user
topic readwrite Configuration
Hello
I created a person in Home Assistant.
I think a user is then created automatically.
My mistake was that I forgot an entry in the Zigbee2mqtt configuration.
>user: the newly created user<
>password: the PSW for this<
The configuration now looks like this.
data_path: /config/zigbee2mqtt
socat:
enabled: false
master: pty,raw,echo=0,link=/tmp/ttyZ2M,mode=777
slave: tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5
options: '-d -d'
log: false
mqtt:
server: mqtt://core-mosquitto:1883
user: the newly created user
password: the PSW for it
serial:
serial: /dev/ttyACM0
adapter: deconz
zigbee_herdsman_debug: true
For the Mosquitto Broker:
logins:
- username: the newly created user
password: the PSW for it
require_certificate: false
certfile: fullchain.pem
keyfile: privkey.pem
customize:
active: false
folder: mosquitto
Then the error disappeared.
This is my first blog entry :-) . Maybe it will help someone