Hi, I’m experiencing a recurring issue with the MQTT integration in Home Assistant.
At random intervals (sometimes once a week, sometimes once a month), the MQTT integration suddenly becomes unavailable and gets disabled due to an authentication error. Nothing changes in the configuration. I’m using the official Mosquitto broker add-on with default credentials, and the broker is running locally. To restore MQTT, I have to manually reconfigure the integration in the UI and submit the form without changing anything.
I started checking logs and noticed that every time this happens, it seems to be correlated with a Supervisor restart (usually caused by a Supervisor update).
From Home Assistant logs:
failed to receive on socket: [Errno 104] Connection reset by peer
Unable to connect to the MQTT broker: Not authorized
Error returned from MQTT server: The connection was lost.
Error returned from MQTT server: The connection was refused.
From the Mosquitto add-on logs:
New connection from 192.168.123.41 on port 1883
Client CEFE2BEF9DD4CF3F577791 disconnected, not authorised.
New connection from 192.168.123.41 on port 1883
Client CEFE2BEF9DD4CF3F577791 disconnected, not authorised.
At the same time, Supervisor logs show a restart and later a successful auth for Mosquitto:
Supervisor restart after closing
Auth request from 'core_mosquitto' for 'mqtt'
Successful login for 'mqtt'
After that point, MQTT works again, but the MQTT integration in Home Assistant remains disabled and requires manual reconfiguration.
This makes me suspect a race condition during Supervisor restart, where the Mosquitto add-on temporarily rejects authentication before the Supervisor auth backend is fully ready, and Home Assistant permanently marks the MQTT integration as failed.
Has anyone seen this behavior before or knows how to prevent the MQTT integration from getting disabled in this situation?