Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while opening serialport 'Error: Error: Permission denied, cannot open /dev/ttyACM0' #22927

Open
mauhl0194 opened this issue Jun 4, 2024 · 5 comments
Labels
problem Something isn't working

Comments

@mauhl0194
Copy link

What happened?

If I try start the zigbee2mqtt via

root@zigbee2mqtt:/opt/zigbee2mqtt# npm start

the following error message appears:

[2024-06-04 11:33:05] info: z2m: Logging to console, file (filename: log.txt)
[2024-06-04 11:33:05] debug: z2m: Can't load state from file /opt/zigbee2mqtt/data/state.json (doesn't exist)
[2024-06-04 11:33:05] info: z2m: Starting Zigbee2MQTT version 1.37.1 (commit #cda867a)
[2024-06-04 11:33:05] info: z2m: Starting zigbee-herdsman (0.46.6)
[2024-06-04 11:33:05] debug: z2m: Using zigbee-herdsman with settings: '{"adapter":{"concurrent":null,"delay":null,"disableLED":true},"backupPath":"/opt/zigbee2mqtt/data/coordinator_backup.json","databaseBackupPath":"/opt/zigbee2mqtt/data/database.db.backup","databasePath":"/opt/zigbee2mqtt/data/database.db","network":{"channelList":[11],"extendedPanID":[221,221,221,221,221,221,221,221],"networkKey":"HIDDEN","panID":6754},"serialPort":{"adapter":"deconz","path":"/dev/ttyACM0"}}'
[2024-06-04 11:33:05] debug: zh:deconz:driver: Set delay to 0
[2024-06-04 11:33:05] debug: zh:controller: Starting with options '{"network":{"networkKeyDistribute":false,"networkKey":[1,3,5,7,9,11,13,15,0,2,4,6,8,10,12,13],"panID":6754,"extendedPanID":[221,221,221,221,221,221,221,221],"channelList":[11]},"serialPort":{"path":"/dev/ttyACM0","adapter":"deconz"},"databasePath":"/opt/zigbee2mqtt/data/database.db","databaseBackupPath":"/opt/zigbee2mqtt/data/database.db.backup","backupPath":"/opt/zigbee2mqtt/data/coordinator_backup.json","adapter":{"disableLED":true,"concurrent":null,"delay":null}}'
[2024-06-04 11:33:05] debug: zh:deconz:driver: Opening with /dev/ttyACM0
[2024-06-04 11:33:05] error: z2m: Error while starting zigbee-herdsman
[2024-06-04 11:33:05] error: z2m: Failed to start zigbee
[2024-06-04 11:33:05] error: z2m: Check https://www.zigbee2mqtt.io/guide/installation/20_zigbee2mqtt-fails-to-start.html for possible solutions
[2024-06-04 11:33:05] error: z2m: Exiting...
[2024-06-04 11:33:05] error: z2m: Error: Error while opening serialport 'Error: Error: Permission denied, cannot open /dev/ttyACM0'
at SerialPort. (/opt/zigbee2mqtt/node_modules/zigbee-herdsman/src/adapter/deconz/driver/driver.ts:202:28)
at SerialPort._error (/opt/zigbee2mqtt/node_modules/@serialport/stream/dist/index.js:82:22)
at /opt/zigbee2mqtt/node_modules/@serialport/stream/dist/index.js:118:18

I have checked everything from the help Zigbee2MQTT fails to start and everything fits.

Can anyone help me?

What did you expect to happen?

Start of the Zigbee2MQTT and access to the frontend

How to reproduce it (minimal and precise)

No response

Zigbee2MQTT version

1.37.1

Adapter firmware version

26780700

Adapter

Deconz Conebee II

Setup

LXC on Proxmox on Intel NUC

Debug log

No response

@mauhl0194 mauhl0194 added the problem Something isn't working label Jun 4, 2024
@LamerTex
Copy link

LamerTex commented Jun 4, 2024

Did you try to run the command with root access?

I had a similar problem (not sure if exactly the same) with "npm start", but it was working correctly with "sudo npm start".

If this works then probably the correct solution is to give access to the serial port to the current user, but I'm not an expert in Linux permissions so I can't help you very much in that case.

@mauhl0194
Copy link
Author

Did you try to run the command with root access?

I had a similar problem (not sure if exactly the same) with "npm start", but it was working correctly with "sudo npm start".

If this works then probably the correct solution is to give access to the serial port to the current user, but I'm not an expert in Linux permissions so I can't help you very much in that case.

That was not the problem. My user has root access...

@LamerTex
Copy link

LamerTex commented Jun 4, 2024

And does the command ls -l /dev/ttyACM0 return the right info as displayed in the installation instruction?

If that command works correctly then I don't know how to help you, let's see if someone else can.

@mauhl0194
Copy link
Author

And does the command ls -l /dev/ttyACM0 return the right info as displayed in the installation instruction?

If that command works correctly then I don't know how to help you, let's see if someone else can.

Yes, I get the right info as seen below:

root@proxmox:~# ls -l /dev/ttyACM0
crw-rw-rw- 1 root dialout 166, 0 Jun 4 13:39 /dev/ttyACM0

@LaurentChardin
Copy link
Sponsor Contributor

LaurentChardin commented Jun 4, 2024

LXC on Proxmox on Intel NUC : LXC on promox is a pain ;-)

You need to do some black magic for the container to be allowed to access the shared resource:
https://forum.proxmox.com/threads/passthrough-usb-device-to-lxc-keeping-the-path-dev-bus-usb-00x-00y.127774/
https://forum.proxmox.com/threads/hard-time-passing-through-usb-to-lxc.129928/

You need to change the PVE configuration in order for the container to re-apply the right permission. And also to actually surface it in the container.

Assuming you are trying to run Z2M in a LXC container.
(and your container needs to be privileged as well)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants