Hassbian + Mosquitto connection refused

Hello,

Everything is working but I got this error constantly repeating:

pi@hassbian:~ $ mosquitto_sub -d -u xxxx -P xxxx -t "#"
Client mosqsub/896-hassbian sending CONNECT
Client mosqsub/896-hassbian received CONNACK
Connection Refused: bad user name or password.
Client mosqsub/896-hassbian sending CONNECT
Client mosqsub/896-hassbian received CONNACK
Connection Refused: bad user name or password.
Client mosqsub/896-hassbian sending CONNECT
Client mosqsub/896-hassbian received CONNACK
Connection Refused: bad user name or password.
Client mosqsub/896-hassbian sending CONNECT
Client mosqsub/896-hassbian received CONNACK
Connection Refused: bad user name or password.

This is my config:

mqtt:
  broker: 192.168.1.211
  port: 1883
  client_id: ha
  username: !secret mosquitto_user
  password: !secret mosquitto_password

Again, everything else is working so I know the broker is running and HASS can publish and read from the broker. Only this error.
Does anybody knows what password or user is not correct?

Erik

Only because I just went through this. Username is case sensitive.

1 Like

User name is correct. Must be something else.

Thanks anyway.

Erik

Maybe a more experienced person can help. You can connect to it from other services/devices?

is mosquitto running ? It has been some trouble for the last couple of weeks with it not launching properly…
see below

No that’s the strange thing. Every thing is working (publish, Subscribe, connect). I can’t find anything that is not working. Only when I do:

pi@hassbian:~ $ mosquitto_sub -d -u xxxx -P xxxx -t "#"

this is scrolling down my terminal:

Client mosqsub/896-hassbian sending CONNECT
Client mosqsub/896-hassbian received CONNACK
Connection Refused: bad user name or password.

I’m not really sure what is trying to connect.

Erik

The mosquitto_sub command is trying to connect. Whatever you are typing in place of xxxx in this command does not match the username or password configured for mosquitto.

I’m very sure that my login is correct. I already added a new user.

Erik

Got this resolved?

Got the same issue on Hassbian.

Edit:
Solved:
If you are running a Mosquitto instance on the same server as Home Assistant then you must ensure that the Mosquitto service starts before Home Assistant. For a Linux instance running Systemd (Raspberry Pi, Debian, Ubuntu and others) then you should edit the file /etc/systemd/system/[email protected] as root (e.g., sudo nano /etc/systemd/system/[email protected]) and add the Mosquitto service: [Unit] Description=Home Assistant After=network.target mosquitto.service