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.

Hi there, sorry for the long time without any response but i was out of order…
I did a lot of investigation and several tests including a complete new installation, the problem still exists.
I fount out that the problem begins with the installation of zigbee2mqtt with openhabian-config.
The installationprocess gives me no error but at the end, when it display’s the window with: “Setup was successful. Zigbee2MQTT is now up and running.” with the OK-Button the mess begins.
It doesn’t matter how long i wait before clicking the OK-Button, the Raspberry crashes without any additional information. I’ve no idea what’s going on. Can anyone give me hint to find out, what causes the RPi to crash after installing zigbee2mqtt?

Kind regards
Achim

It crashes means you get no prompt and cannot ping the Pi anymore?
Does it boot after switching it off and on?
What messages do you see when you connect a monitor before it crashes?
I have never tried with a Pi3 (a little low for my taste), but I never had problems with Pi4 and Pi5.

I would try

  • temporarily disable ZRAM
  • then install Zigbee2MQTT
  • does this work ?
  • if yes enable ZRAM again
  • if not what do the log files show ? I would exepct that the log files have to show something
  • enable ZRAM again

Hi there,
thanks for the help.
I put a display on my RPi and made a update with openhabian-config.
After that i had no problems installing zigbee2mqtt! The installation worked without crashing the RPi and zigbee2mqtt worked, still after a reboot.
My problems are gone, but i have no idea why?!?!

Thanks for any suggestions and your immediate responses.

Best Regards
Achim