Overview
When uploading a sketch you may get the following error
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
or, when opening the serial Monitor
Error opening serial port '/dev/ttyACM0
Note: The number in
ttyACM*
may be different.
If this happens, start by ensuring that you are using the correct port:
- Arduino IDE: Tools > Port > [select port]
- Web Editor: Select port using the dropdown.
If the problem persists there may be an issue with permissions for the serial port. See below for step-by-step instructions on how to set the correct permissions.
How to set serial port permissions
Open Terminal and type
ls -l /dev/ttyACM*
Press enter. Terminal will return something like
crw-rw---- 1 root dialout 188, 0 5 apr 23.01 ttyACM0
What we are interested in is the group name, which is probably called dialout
.
Note: The number at the end of
ttyACM
may be different, or multiple entries might be returned.
Now we want to add your user to that group. Input the following command in the terminal, replacing <group>
with the group name from above, and <username>
with your username, both without brackets.
sudo usermod -a -G <group> <username>
Press enter. Input password if prompted.
Lastly, for the new permissions to take effect, you need to log out and in to your user account.
You can verify the changes by typing
groups
into the Terminal and pressing Enter. The group you added should appear in the list.