Zigbee2mqtt fails to start on freshly installed openhabian

  • Platform information:
    • Hardware: Raspberry Pi 3b+
    • OS: Openhabian
    • Java Runtime Environment: openjdk 17.0.10 2024-01-16
    • openHAB version: 4.1.2

Hello there,
for upgrade-reason from stretch to bookworm i did a fresh installation of openhabian. Openhabian is up and running without any problems, installation of Mosquitto and zigbee2mqtt via openhabian-config worked also without error. Trying to use the zigbee2mqtt configuration page is not possible so i looked for the log-files and identified an error starting zigbee2mqtt as a service.
There is no log-file-directory for zigbee2mqtt and so there are no log-files written.
Looking in the the system-journal i found the following information:

==========================
Mar 27 10:15:54 openhabian systemd[1]: Started zigbee2mqtt.service - Zigbee2MQTT.
Mar 27 10:15:57 openhabian npm[20207]: > zigbee2mqtt@1.36.0 start
Mar 27 10:15:57 openhabian npm[20207]: > node index.js
Mar 27 10:16:08 openhabian npm[20219]: Error: EACCES: permission denied, mkdir '/var/log/zigbee2mqtt'
Mar 27 10:16:08 openhabian npm[20219]:     at Object.mkdirSync (node:fs:1391:3)
Mar 27 10:16:08 openhabian npm[20219]:     at mkdirSyncRecursive (/opt/zigbee2mqtt/node_modules/mkdir-recursive/index.js:199:16)
Mar 27 10:16:08 openhabian npm[20219]:     at mkdirSyncRecursive (/opt/zigbee2mqtt/node_modules/mkdir-recursive/index.js:197:12)
Mar 27 10:16:08 openhabian npm[20219]:     at mkdirSyncRecursive (/opt/zigbee2mqtt/node_modules/mkdir-recursive/index.js:197:12)
Mar 27 10:16:08 openhabian npm[20219]:     at Object.mkdirSync (/opt/zigbee2mqtt/node_modules/mkdir-recursive/index.js:82:10)
Mar 27 10:16:08 openhabian npm[20219]:     at Object.init (/opt/zigbee2mqtt/lib/util/logger.ts:43:12)
Mar 27 10:16:08 openhabian npm[20219]:     at new Controller (/opt/zigbee2mqtt/lib/controller.ts:62:16)
Mar 27 10:16:08 openhabian npm[20219]:     at start (/opt/zigbee2mqtt/index.js:106:18)
Mar 27 10:16:08 openhabian npm[20219]:     at processTicksAndRejections (node:internal/process/task_queues:95:5)
Mar 27 10:16:08 openhabian systemd[1]: zigbee2mqtt.service: Main process exited, code=exited, status=1/FAILURE
Mar 27 10:16:08 openhabian systemd[1]: zigbee2mqtt.service: Failed with result 'exit-code'.
Mar 27 10:16:08 openhabian systemd[1]: zigbee2mqtt.service: Consumed 18.364s CPU time.
Mar 27 10:16:08 openhabian systemd[1]: zigbee2mqtt.service: Scheduled restart job, restart counter is at 9714.
Mar 27 10:16:08 openhabian systemd[1]: Stopped zigbee2mqtt.service - Zigbee2MQTT.
Mar 27 10:16:08 openhabian systemd[1]: zigbee2mqtt.service: Consumed 18.364s CPU time.
==========================

So there is a never-ending loop trying to start the zigbee2mqtt service.
Stopping the service and trying to create the log-directory manually causes the system to hard crash.

Could anybody help me and give me a hint where the problem is and how to fix it.

This looks like it could be just a Linux permissions issue. You need to change the owner of the folder /var/log/zigbee2mqtt to be the same as that of the user that runs zigbee2mqtt.

You’ll be able to identify the user by looking at the zigbee2mqtt.service file. While your at you I would make sure the same user owns the /opt/zigbee2mqtt folder. That way it keeps things in sync.

Hi Maximo,
maybe i didn’t describe the problem in a precise manner. Creating the directory manually with the appropiate permissions didn’t change anything. It crashes the system and i need to reboot. After the reboot the directory is gone…

Hi Achim,
the problem you describe is really weird. But to be sure that we really understand your problem, it would be a good idea to post the output of the command “ls -l” of the log directory that you created.

With kindest regards
Joerg

/var/log is on zram, so you need a proper shutdown to make the directory reappear after next reboot.
I guess that never happened.
You can manually create the directory or (preferred) remove zigbee2mqtt with openhabian-config and reinstall it. After successful creation do a proper reboot so that zram gets written do sd-card. If anything goes wrong please report so I can try to fix.