MQTT Broker not working on bootup?

I’m having a problem with MQTT, it seems like when the server (hypervisor) is rebooted the MQTT service doesn’t properly reconnect to the MQTT broker.

I see the error in my log:

2022-10-02 19:08:55.537 ERROR (Thread-2 (_thread_main)) [homeassistant.components.mqtt.client] Unable to connect to the MQTT broker: Connection Refused: not authorised.
2022-10-02 19:08:55.538 WARNING (Thread-2 (_thread_main)) [homeassistant.components.mqtt.client] Disconnected from MQTT server 192.168.1.221:1883 (5)

I also can verify this I can’t connect to it from a PC with MQTT Explorer.

It seems like the MQTT addon isn’t starting correctly on system boot?

Although it looks like its running in the Addon, it apparently isn’t:

But oddly, if I simply click “Restart” on the MQTT Broker addon it magically all works again?

And then all my errors are gone and sensors magically appear?

Do you have any errors in the log for the mqtt addon? Ie the log tab on your screenshot?

I looked, but it seemed not particularly useful.

Restart hypervisor, look at addon:

After manual addon restart:

I think because you have a 1 sec update the actual part of the log that maybe of interest is rolling of the top. You should have something like this when it starts (that hopefully shows you some error)

s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
cont-init: info: running /etc/cont-init.d/mosquitto.sh
[00:58:09] INFO: SSL is not enabled
cont-init: info: /etc/cont-init.d/mosquitto.sh exited 0
cont-init: info: running /etc/cont-init.d/nginx.sh
cont-init: info: /etc/cont-init.d/nginx.sh exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun mosquitto (no readiness notification)
services-up: info: copying legacy longrun nginx (no readiness notification)
s6-rc: info: service legacy-services successfully started
[00:58:09] INFO: Starting NGINX for authentication handling...
[00:58:10] INFO: Starting mosquitto MQTT broker...
2022-10-03 00:58:10: Warning: Mosquitto should not be run as root/administrator.
[00:58:10] INFO: Successfully send discovery information to Home Assistant.
[00:58:10] INFO: Successfully send service information to the Supervisor.

Also maybe turn on debug in the config.

My guess is there are just too many things being published and its pushing out of the log, its like that all the way to the end of the page where the refresh button is, I can’t scroll back far enough to see startup. I tried disabling rtl4332mqtt and now I can see the startup

Hypervisor reboot:

Manual restart addon:

Seems this is a known issue.

There is a possible work around if you read through the comments on the issue.

Interesting, I hadn’t seen that in my research (and this is a new problem for me at least).

I’ll dig thru that thread, thank you.