# Error accessing GPIO chips: Permission denied

**URL:** https://discourse.nodered.org/t/error-accessing-gpio-chips-permission-denied/96984
**Category:** General
**Tags:** docker
**Created:** [9 May 2025 10:07 UTC](https://discourse.nodered.org/t/error-accessing-gpio-chips-permission-denied/96984 "2025-05-09T10:07:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Forhorse](https://avatars.discourse-cdn.com/v4/letter/f/ebca7d/32.png) [@Forhorse](https://discourse.nodered.org/u/Forhorse)
#### Post date: [9 May 2025 10:07 UTC](https://discourse.nodered.org/t/error-accessing-gpio-chips-permission-denied/96984/1 "2025-05-09T10:07:59Z")

</div>

Hello,

I'm trying to interact with the GPIOs of a Radxa Rock3A through Node-red.  
Node-Red is in a Docker container.  
According to what I found on the internet, node-red-contrib-libgpiod are the solution.  
The requirements for these nodes are not in the prebuild NodeRED images so I compiled my own image.

Editing Dockerfile.debian, add :

```auto
apt install gpiod libgpiod-dev libgpiod-doc libnode-dev
npm i node-libgpiod

```

Then build the image without problem.  
Setting up the container also goes smoothly  
my docker compose file :

```auto
services:
  node-red:
    container_name: nodered_1
    image: node-red-build:node-red-libgpiod
    privileged: true
    restart: always
    environment:
      - TZ=Europe/Paris
    ports:
      - "1880:1880"
    volumes:
      - node_red_data:/data
    devices:
       - "/dev/gpiochip0:/dev/gpiochip0:rwm"
       - "/dev/gpiochip1:/dev/gpiochip1:rwm"
       - "/dev/gpiochip2:/dev/gpiochip2:rwm"
       - "/dev/gpiochip3:/dev/gpiochip3:rwm"
volumes:
  node_red_data:

```

The first problem occurs when I want to install the palett "node-red-contrib-libgpiod"

```auto
2025-05-09T09:40:52.950Z Installer : node-red-contrib-libgpiod 0.0.1

2025-05-09T09:40:51.244Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --omit=dev --engine-strict node-red-contrib-libgpiod@0.0.1
2025-05-09T09:40:54.395Z [err] npm error code EACCES
2025-05-09T09:40:54.396Z [err] npm error syscall open
2025-05-09T09:40:54.396Z [err] npm error path /data/.npm/_cacache/tmp/e68164e8
2025-05-09T09:40:54.397Z [err] npm error errno EACCES
2025-05-09T09:40:54.398Z [err] npm error
2025-05-09T09:40:54.398Z [err] npm error Your cache folder contains root-owned files, due to a bug in
2025-05-09T09:40:54.398Z [err] npm error previous versions of npm which has since been addressed.
2025-05-09T09:40:54.398Z [err] npm error
2025-05-09T09:40:54.398Z [err] npm error To permanently fix this problem, please run:
2025-05-09T09:40:54.398Z [err] npm error sudo chown -R 1000:1000 "/data/.npm"
2025-05-09T09:40:54.403Z [err] npm error Log files were not written due to an error writing to the directory: /data/.npm/_logs
2025-05-09T09:40:54.403Z [err] npm error You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
2025-05-09T09:40:54.424Z rc=1

```

I therefore apply the proposed solution (loged as root inside the container)

```auto
chown -R 1000:1000 "/data/.npm"

```

And the pallet installs correctly (Is the proposed solution correct?)

Then I place a node from this palett on the flow (ie. "GPIO in") with a correct setting like

- device : gpiochip1
- pin : 0
- name : pin-03

then I deploy the flow. This is where I have a second problem. The node indicates "Unable to open device"

If in the container console i run "_gpioinfo_" as root, the command return the list of the gpio in the _/dev/gpiochip_ but the same command as user node-red return :

> gpioinfo: error accessing GPIO chips: Permission denied

So the user running NodeRED (node-red) does not have rights access to peripherals.  
After a long search on the internet I found a workaround, running as root :

```auto
chmod a+rw /dev/gpiochip*

```

Then redeploy the flow and it work ! 🤩

But there is a third problem that I have not been able to solve.  
This workaround is temporary and does not survive a reboot !  
How can we make this solution (or an other?) sustainable?

Thank you.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [7 August 2025 10:08 UTC](https://discourse.nodered.org/t/error-accessing-gpio-chips-permission-denied/96984/2 "2025-08-07T10:08:27Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
