Fix "can't open device /dev/ttyUSB0: Permission denied" (Arduino, ESP32)
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
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.
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
- User not in the serial group:
dialouton Debian, Ubuntu, Raspberry Pi OS and Fedora,uucpon Arch. After adding it, you must log in again. - Busy port: Serial Monitor open, another IDE,
screen, or ModemManager probing/dev/ttyACM*ports right after plugging in. - brltty grabs the CH340: on Ubuntu, this braille display service claims the CH340 USB ID and the port disappears immediately.
- Port not found: missing CH340 or CP210x driver (Windows, older macOS), charge-only cable, or wrong port name (
/dev/ttyUSB0instead of/dev/ttyACM0, old COM number). - Snap or Flatpak IDE: the sandbox can block serial port access; the official archive or AppImage avoids this.
Step-by-step fix
-
Identify the port and its permissions
Plug in the board, then check which device appears and which group owns it.
dmesgalso shows whether the driver (ch341, cp210x, cdc_acm) loaded or brltty grabbed it.ls -l /dev/ttyUSB* /dev/ttyACM* # crw-rw---- 1 root dialout 188, 0 ... /dev/ttyUSB0 sudo dmesg | tail -n 20 groups -
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.
newgrpapplies the group to the current terminal only.# 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 -
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.
sudo lsof /dev/ttyUSB0 sudo systemctl stop ModemManager # Only if you do not use a braille display sudo apt remove brltty -
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 withlsusb(here 1a86:7523 for a CH340; 10c4:ea60 for a CP2102).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 -
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.# Windows (PowerShell): list available COM ports [System.IO.Ports.SerialPort]::GetPortNames() # macOS ls /dev/cu.* -
Avoid chmod 666 and sudo
A
sudo chmod 666 /dev/ttyUSB0only lasts until the next replug and opens the port to every user on the machine. Running the IDE withsudocreates root-owned files in your home folder and breaks later launches. Thedialoutgroup 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
dialoutgroup right away. - Use a udev rule with a
SYMLINKto 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
- Fix "avrdude: stk500_getsync(): not in sync" on Arduino
- Fix "Failed to connect to ESP32" (Wrong boot mode, No serial data received)
- Fix "Brownout detector was triggered" on ESP32
- Fix "Guru Meditation Error: Core 1 panic'ed (LoadProhibited)" on ESP32
- Fix "error: 'x' was not declared in this scope" (Arduino, C++)
- Fix "Sketch too big" on Arduino and ESP32 (flash memory full)
- Fix "OSError: [Errno 121] Remote I/O error" with I2C on Raspberry Pi