MQTT Connection Refused: not authorised

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?

4 Likes

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?

2 Likes

My current version is:

Home Assistant 2023.10.5
Supervisor 2023.10.0
Operating System 11.0
Frontend 20231005.0 - latest

Any updates? I also have the problem, that the client is disconnected, not authorized.
I’m trying to run zigbee2MQTT

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.

1 Like

I don’t know what it is but I came here to say I think creating a new account fixed my similar problems.

There seems to be issue with Home Assistant user update feature.

What I had done was first create mqtt-user by seeing some random tutorial of mqtt setup.

Later changed that user just update username to mqtt_user. And although it changed in UI seemed like it did not change in the system.

So using mqtt_user never worked.

When I tried to make another new user with username mqtt-user it said user already exists. But I had already changed mqtt-user to mqtt_user.

Long story short:
Solution: delete all mqtt user and create a new one.

1 Like

I got it working mqtt with Mosquitto addon on HAOS.
* Core2024.11.1
* Supervisor2024.11.2
* Operating System13.2
Steps:

  1. via Settings/people/users: create the user used for Mqtt with password - local login only - eg my-mqtt-user
  2. with the Add-on “Terminal & SSH” create the directory /share/mosquitto
  3. 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

1 Like
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