Arduino upload error

avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied

avrdude could not open the serial port at all, before it talked to the board. Permission denied, Access is denied and Resource busy are three versions of the same problem.

  • Upload error
  • 3 common causes
The message

What the Arduino IDE prints

Output window
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
ioctl("TIOCMGET"): Inappropriate ioctl for device
Failed uploading: uploading error: exit status 1

Either your account may not use the port, or another program already has it.

Causes

The 3 usual causes in order

1Permission denied on Linux

Serial ports belong to a group, usually dialout or uucp. Your user is not in it.

  1. Run sudo usermod -a -G dialout $USER, then log out and back in.
  2. On Arch based systems the group is uucp.

2Another program has the port

A Serial Monitor, a second IDE window, a terminal program or a 3D printer host can hold it.

  1. Close the Serial Monitor and every other serial program.
  2. On Linux, ModemManager can grab new serial devices. Stop it, or remove it, and plug the board in again.

3The port number changed

After a reset or a re-plug, the board may appear as a different port.

  1. Open Tools, Port again and pick the entry that is there now.
  2. On Windows, "Access is denied" on a COM port also means the board was unplugged during the upload.
On a real board

What to do at the bench

The error is about the computer, not the sketch or the board. Fix the permission or the program that holds the port, and the upload then starts.

Run the sketch in Mokxi before you blame the board. If it builds and runs there, the code is fine and the problem is the connection to the real board.

Test the sketch in Mokxi first

Run the sketch here before you blame the board. If it builds and runs in Mokxi, the code is fine and the fault is the connection to the real board. Mokxi never uploads in a simulation, so it cannot raise this error itself.

A sketch to try first
void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  Serial.println("blink ready");
}

void loop() {
  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(500);
}

Run it in Mokxi

FAQ

Questions and answers

What does ser_open mean?

It is the part of avrdude that opens the serial port. If it fails, nothing was sent to the board.

Why "Permission denied"?

Your user account is not allowed to use serial ports. On Linux, add it to the dialout group.

Why "Resource busy"?

A program already has the port open. Close it and try again.