Zigbee2MQTT suddenly no longer connecting to server - "MQTT error: read ECONNRESET"

I’ve been running a Zigbee2MQQT add on and the Mosquitto broker for months now, with no issues at all until suddnely today I noticed my zigbee devices were all not responding.

Jumped on and restarted home assistant and then came back and they were still down. Tried restarting just zigbee2MQTT, as well as a full reboot of the raspberry pi. Not working.

In the z2m add on I checked the logs and found it was not connecting properly to the MQTT server:

Zigbee2MQTT:info  2023-09-24 12:34:04: Zigbee: disabling joining new devices.
Zigbee2MQTT:info  2023-09-24 12:34:04: Connecting to MQTT server at mqtt://192.168.0.137:1883
Zigbee2MQTT:error 2023-09-24 12:34:07: MQTT error: read ECONNRESET
Zigbee2MQTT:error 2023-09-24 12:34:07: MQTT failed to connect, exiting...
Zigbee2MQTT:info  2023-09-24 12:34:07: Stopping zigbee-herdsman...
Zigbee2MQTT:error 2023-09-24 12:34:08: MQTT error: read ECONNRESET
Zigbee2MQTT:error 2023-09-24 12:34:09: MQTT error: read ECONNRESET
Zigbee2MQTT:error 2023-09-24 12:34:11: MQTT error: read ECONNRESET
Zigbee2MQTT:error 2023-09-24 12:34:14: MQTT error: read ECONNRESET
Zigbee2MQTT:info  2023-09-24 12:34:17: Stopped zigbee-herdsman

Above that part of the log file is it listing my many devices before it gets to that part. I can see further up it’s finding the coordinator (sonoff dongle-P) with no troubles.

As far as I know, nothing has changed in terms of router settings. My Raspberry pi/HA instance is still on that IP address. I’ve tried a few other things in the configuration of Zigbee2MQTT like removing all user info and server addresses (and trying ‘mqtt:core-mosquitto/1883’ which causes it try to connect to a different IP address but it still fails.

I tried resintalling Z2M add on.

Not really sure what to do, but I can’t turn on and off any of my lights which is not ideal! Any ideas?

Ok, I’ve managed to fix it. Found that Mosquitto broker add on had errors in the log causing it to restart over and over which allowed me to troubleshoot that issue first.

Seems lots of people are having problems with Mosquitto broker 6.3.1, and so I had to revert to the back up of 6.2.1. Problem was immediately resolved.

Ran into the same issues. Did you have to uninstall and then install 6.2.1?

This is my log for the Mosquitto Broker start. Anyone know what is causing the problem?

s6-rc: info: service s6rc-oneshot-runner: starting
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
[11:50:06] INFO: Setting up user mqtt-user
[11:50:06] INFO: Certificates found: SSL is available
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)
[11:50:07] INFO: Starting NGINX for authentication handling...
s6-rc: info: service legacy-services successfully started
[11:50:07] INFO: Starting mosquitto MQTT broker...
2023-11-02 11:50:07: Warning: Mosquitto should not be run as root/administrator.
mosquitto: persist_read.c:550: persist__restore_sub: Assertion `client_id' failed.
[11:50:08] INFO: Service restart after closing
[11:50:09] INFO: Starting mosquitto MQTT broker...
2023-11-02 11:50:09: Warning: Mosquitto should not be run as root/administrator.
mosquitto: persist_read.c:550: persist__restore_sub: Assertion `client_id' failed.
[11:50:09] INFO: Service restart after closing

I just uninstalled and reinstalled Mosquitto Broker 6.3.1. When editing the configuration I noticed a small message on the config screen below.

So I didn’t add a user and both Mosquitto Broker and MQTT started normally.

1 Like

Unrelated, but recently I actually had to reinstall home assistant from a back up that meant I was stuck with 6.3.1 and no way to downgrade which is what fixed the problem for me last time. Not sure if the below will work for you, but it definitely worked for me.

I managed to find a post somewhere on the community forums (which of course I can’t find now), but it suggested that I needed to update the MQTT integration configuration with the ‘user’ details that I created as the MQTT user.

So go to settings → devices and services → MQTT. and then hit configuration and then the “re-configure MQTT” button. My details now look like the screenshot below, but I can’t remember what was there beforehand and I can’t find that post.