Ad Space — Top Banner

GPIO Permission Denied

Raspberry Pi Single-Board Computer

Severity: Minor

What Does This Error Mean?

Permission Denied when accessing GPIO means your user does not have the required permissions. You either need to run with sudo or add your user to the gpio group. Run: sudo usermod -aG gpio $USER then log out and back in.

Affected Models

  • Raspberry Pi 5
  • Raspberry Pi 4B
  • Raspberry Pi 3B+
  • All Raspberry Pi models

Common Causes

  • User not in the gpio group
  • Running Python script without sudo
  • GPIO library requires root access
  • New user account without proper group membership
  • Raspberry Pi OS Bookworm changed GPIO access model

How to Fix It

  1. Add your user to the gpio group.

    Run: sudo usermod -aG gpio $USER Then log out and back in (or reboot).

  2. Or run your script with sudo.

    sudo python3 my_script.py This gives root access to GPIO. Less secure but works immediately.

  3. On Pi 5 / Bookworm: use lgpio or gpiozero instead of RPi.GPIO.

    Raspberry Pi OS Bookworm changed the GPIO access model. The older RPi.GPIO library may not work. Use gpiozero or lgpio instead.

  4. Check if GPIO is enabled: ls /dev/gpio*

    If no GPIO devices appear, GPIO may be disabled. Enable with: sudo raspi-config > Interface Options > GPIO.

Frequently Asked Questions

Why did GPIO access change in Bookworm?

Raspberry Pi OS Bookworm moved to a new GPIO driver (RP1 on Pi 5) that uses a different access model. The old RPi.GPIO library used /dev/mem which required root. The new approach is more secure.

Which GPIO library should I use?

gpiozero: simplest, recommended for beginners. lgpio: low-level, works on Pi 5. RPi.GPIO: older, may not work on Pi 5 / Bookworm.