Skip to content
FR
  1. LuzineDebug
  2. Electronics & Arduino
  3. avrdude: ser_open(): can't open device "/dev/tty…
Electronics & Arduino Beginner ≈ 5 min to fix

Fix "can't open device /dev/ttyUSB0: Permission denied" (Arduino, ESP32)

Error message
avrdude: ser_open(): can't open device "/dev/ttyUSB0": Permission denied
  • avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
  • serial.serialutil.SerialException: [Errno 13] could not open port /dev/ttyUSB0: [Errno 13] Permission denied: '/dev/ttyUSB0'
  • avrdude: ser_open(): can't open device "/dev/ttyUSB0": No such file or directory
  • avrdude: ser_open(): can't open device "\\.\COM3": The system cannot find the file specified.
  • avrdude: ser_open(): can't open device "/dev/ttyACM0": Device or resource busy
In short

On Linux, your user is not allowed to open the serial port. Add it to the dialout group (or uucp on Arch), then log out and back in. If the port does not exist at all, it is a cable, driver (CH340, CP210x) or port name issue.

Be the first to confirm this fix

What this error means

On Linux, each serial port is a special file such as /dev/ttyUSB0 or /dev/ttyACM0. It usually belongs to root and the dialout (or uucp) group, with crw-rw---- permissions. A user outside that group can neither read nor write it, so avrdude, esptool or pyserial get "Permission denied". The "No such file or directory" or "cannot find the file specified" (Windows) variants mean something else: the given port does not exist, because the board is not detected or the name is wrong.

Common causes

  1. User not in the serial group: dialout on Debian, Ubuntu, Raspberry Pi OS and Fedora, uucp on Arch. After adding it, you must log in again.
  2. Busy port: Serial Monitor open, another IDE, screen, or ModemManager probing /dev/ttyACM* ports right after plugging in.
  3. brltty grabs the CH340: on Ubuntu, this braille display service claims the CH340 USB ID and the port disappears immediately.
  4. Port not found: missing CH340 or CP210x driver (Windows, older macOS), charge-only cable, or wrong port name (/dev/ttyUSB0 instead of /dev/ttyACM0, old COM number).
  5. Snap or Flatpak IDE: the sandbox can block serial port access; the official archive or AppImage avoids this.

Step-by-step fix

  1. Identify the port and its permissions

    Plug in the board, then check which device appears and which group owns it. dmesg also shows whether the driver (ch341, cp210x, cdc_acm) loaded or brltty grabbed it.

    bash
    ls -l /dev/ttyUSB* /dev/ttyACM*
    # crw-rw---- 1 root dialout 188, 0 ... /dev/ttyUSB0
    sudo dmesg | tail -n 20
    groups
  2. Add your user to the group

    Add your account to the group that owns the port, then log out and back in (or reboot): groups are only read at login. newgrp applies the group to the current terminal only.

    bash
    # Debian, Ubuntu, Raspberry Pi OS, Fedora
    sudo usermod -aG dialout $USER
    # Arch Linux, Manjaro
    sudo usermod -aG uucp $USER
    
    # Current shell only, without logging out
    newgrp dialout
  3. Free the port

    Close the Serial Monitor and check which process holds the port. If ModemManager probes it, stop it. If brltty grabs your CH340 and you do not use a braille display, uninstall it.

    bash
    sudo lsof /dev/ttyUSB0
    sudo systemctl stop ModemManager
    # Only if you do not use a braille display
    sudo apt remove brltty
  4. Create a udev rule (optional)

    For a specific board, a udev rule sets the permissions and creates a stable name such as /dev/arduino. Get the ID with lsusb (here 1a86:7523 for a CH340; 10c4:ea60 for a CP2102).

    bash
    echo 'SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", MODE="0660", GROUP="dialout", SYMLINK+="arduino"' | sudo tee /etc/udev/rules.d/99-arduino.rules
    sudo udevadm control --reload-rules
    sudo udevadm trigger
  5. Windows and macOS: check the driver and port name

    On Windows, open Device Manager > Ports (COM & LPT): an unknown device with a yellow triangle means the CH340 (WCH) or CP210x (Silicon Labs) driver is missing. On macOS, ports are named /dev/cu.usbserial-* or /dev/cu.usbmodem*; recent versions recognize most CH340 chips, otherwise install the manufacturer's driver and allow it in System Settings > Privacy & Security.

    bash
    # Windows (PowerShell): list available COM ports
    [System.IO.Ports.SerialPort]::GetPortNames()
    # macOS
    ls /dev/cu.*
  6. Avoid chmod 666 and sudo

    A sudo chmod 666 /dev/ttyUSB0 only lasts until the next replug and opens the port to every user on the machine. Running the IDE with sudo creates root-owned files in your home folder and breaks later launches. The dialout group or a udev rule is the right fix.

Did this fix work for you?

Confirm it in one click: it will rise for the next developers stuck on the same error.

Keep it from coming back

  • On a fresh Linux or Raspberry Pi install, add your user to the dialout group right away.
  • Use a udev rule with a SYMLINK to get a stable port name in your scripts.
  • Let only one program open the port at a time: close the Serial Monitor before uploading.

Frequently asked questions

Do I need to reboot after usermod -aG dialout?

Logging out and back in is enough. To test right away in one terminal, newgrp dialout applies the group to that shell only.

What is the difference between /dev/ttyUSB0 and /dev/ttyACM0?

ttyUSB is for USB-serial converter chips (CH340, CP210x, FTDI). ttyACM is for native USB CDC (Uno with ATmega16U2, Leonardo, ESP32-S3 on native USB, Raspberry Pi Pico).

Permission denied on a Raspberry Pi's /dev/serial0, what do I do?

Add your user to the dialout group, then in sudo raspi-config > Interface Options > Serial Port, answer "no" to the serial login shell and "yes" to the hardware serial port, and reboot.

Useful tools for this error

More Electronics & Arduino errors

All Electronics & Arduino errors →