# Serial permission denied /dev/ttyUSB0

**URL:** https://discourse.nodered.org/t/serial-permission-denied-dev-ttyusb0/68889
**Category:** General
**Created:** [11 October 2022 21:45 UTC](https://discourse.nodered.org/t/serial-permission-denied-dev-ttyusb0/68889 "2022-10-11T21:45:34Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![sudomac](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sudomac](https://discourse.nodered.org/u/sudomac)
#### Post date: [11 October 2022 21:45 UTC](https://discourse.nodered.org/t/serial-permission-denied-dev-ttyusb0/68889/1 "2022-10-11T21:45:34Z")

</div>

node-red-node-serialport error "[serialconfig:e2b92f3a20e71366] serial port /dev/ttyUSB0 error: Error: Error: Permission denied, cannot open /dev/ttyUSB0"

I am using Ubuntu.  
I looked through previous threads about this problem and none of the solutions in those closed topics work. My very simple flow is:  
[  
{  
"id": "583893684f251417",  
"type": "tab",  
"label": "Flow 1",  
"disabled": false,  
"info": "",  
"env":   
},  
{  
"id": "d534b93de04fb7cf",  
"type": "serial in",  
"z": "583893684f251417",  
"name": "",  
"serial": "e2b92f3a20e71366",  
"x": 110,  
"y": 80,  
"wires": [  
[  
"c5d4981ec4bf344c"  
]  
]  
},  
{  
"id": "c5d4981ec4bf344c",  
"type": "debug",  
"z": "583893684f251417",  
"name": "debug 1",  
"active": true,  
"tosidebar": true,  
"console": false,  
"tostatus": false,  
"complete": "false",  
"statusVal": "",  
"statusType": "auto",  
"x": 460,  
"y": 100,  
"wires":   
},  
{  
"id": "e2b04f636b69d499",  
"type": "serial out",  
"z": "583893684f251417",  
"name": "",  
"serial": "e2b92f3a20e71366",  
"x": 450,  
"y": 160,  
"wires":   
},  
{  
"id": "19aa0165634f8bb6",  
"type": "inject",  
"z": "583893684f251417",  
"name": "",  
"props": [  
{  
"p": "payload"  
},  
{  
"p": "topic",  
"vt": "str"  
}  
],  
"repeat": "",  
"crontab": "",  
"once": false,  
"onceDelay": 0.1,  
"topic": "",  
"payload": "!SP1",  
"payloadType": "str",  
"x": 110,  
"y": 160,  
"wires": [  
[  
"e2b04f636b69d499",  
"7c670b79f98c3d76"  
]  
]  
},  
{  
"id": "4fd1653dfa1cea1d",  
"type": "inject",  
"z": "583893684f251417",  
"name": "",  
"props": [  
{  
"p": "payload"  
},  
{  
"p": "topic",  
"vt": "str"  
}  
],  
"repeat": "",  
"crontab": "",  
"once": false,  
"onceDelay": 0.1,  
"topic": "",  
"payload": "!SP0",  
"payloadType": "str",  
"x": 110,  
"y": 200,  
"wires": [  
[  
"e2b04f636b69d499",  
"7c670b79f98c3d76"  
]  
]  
},  
{  
"id": "7c670b79f98c3d76",  
"type": "debug",  
"z": "583893684f251417",  
"name": "debug 2",  
"active": true,  
"tosidebar": true,  
"console": false,  
"tostatus": false,  
"complete": "false",  
"statusVal": "",  
"statusType": "auto",  
"x": 440,  
"y": 200,  
"wires":   
},  
{  
"id": "e2b92f3a20e71366",  
"type": "serial-port",  
"serialport": "/dev/ttyUSB0",  
"serialbaud": "9600",  
"databits": "8",  
"parity": "none",  
"stopbits": "1",  
"waitfor": "",  
"dtr": "none",  
"rts": "none",  
"cts": "none",  
"dsr": "none",  
"newline": "\n",  
"bin": "false",  
"out": "char",  
"addchar": "",  
"responsetimeout": "10000"  
}  
]  
I can use other serial monitors to use this port, accept node red. I see multiple closed threads that offer different fixes for this however I can not get any of them to work.  
The user node red is running under is "joe"

joe@RoemerAutomation:~$ sudo usermod -a -G tty node-red  
[sudo] password for joe:  
usermod: user 'node-red' does not exist

joe@RoemerAutomation:~$ ls -l /dev/ttyUSB0  
crw-rw---- 1 root dialout 188, 0 Oct 11 15:47 /dev/ttyUSB0

joe@RoemerAutomation:~$ groups  
joe adm dialout cdrom sudo dip plugdev lpadmin lxd sambashare

Any thoughts?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [11 October 2022 21:56 UTC](https://discourse.nodered.org/t/serial-permission-denied-dev-ttyusb0/68889/2 "2022-10-11T21:56:10Z")

</div>

> [@sudomac](#):
>
> Error: Permission denied, cannot open /dev/ttyUSB0"

From a quick search...

> Double-check that the cable is exposed as `/dev/ttyUSB0`. I use the `@serialport/list` package for that.

> Double-check that the user running node-red can access /dev/ttyUSB0. It it a member of the `dialout` group?

> Double-check that no other program has opened the port: `lsof /dev/ttyUSB0`

---

<div class="post-metadata">

### Author: ![sudomac](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sudomac](https://discourse.nodered.org/u/sudomac)
#### Post date: [11 October 2022 22:09 UTC](https://discourse.nodered.org/t/serial-permission-denied-dev-ttyusb0/68889/3 "2022-10-11T22:09:32Z")

</div>

`@serialport/list` did not work. I used "dmesg | grep tty"

joe@RoemerAutomation:~$ dmesg | grep tty  
[0.161839] printk: console [tty0] enabled  
[0.515849] serial8250: ttyS0 at I/O 0x3f8 (irq = 4, base\_baud = 115200) is a 16550A  
[81.848951] usb 1-2.3: Keyspan 1 port adapter converter now attached to ttyUSB0  
[93.180504] audit: type=1400 audit(1665521279.474:73): apparmor="DENIED" operation="open" profile="snap.node-red.node-red" name="/dev/ttyUSB0" pid=1188 comm="node" requested\_mask="wr" denied\_mask="wr" fsuid=0 ouid=0

`lsof /dev/ttyUSB0` returns nothing.

The same user "joe" can access the serial port using CuteCom, and Arduino IDE, seperatly of course!

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [11 October 2022 22:25 UTC](https://discourse.nodered.org/t/serial-permission-denied-dev-ttyusb0/68889/4 "2022-10-11T22:25:51Z")

</div>

Please paste code and logs inside preformatted text tags - see the `</>` icon.

What user is running the node-red process? Do you have it starting up using systemd? If so, did you specify a userid in the startup script? If not, then node-red is possibly running as root or some other user. (probably not root since that would give access of course). So you may want to run a `top` command (I use `htop` personally) which should let you see which user owns the node-red process.

Incidentally, you would be better off avoiding `ttyUSB0` since if you ever have \>1 device attached, you can never be certain which will grab the zero device upon reboot. Best to use the serial/by-id dev entry which should always be static.

```auto
$ ls -l /dev/serial/by-id/
total 0
lrwxrwxrwx 1 root root 13 Oct 11 12:28 usb-1a86_USB_Serial-if00-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Oct 8 18:27 usb-RFXCOM_RFXtrx433_A1Y06XVZ-if00-port0 -> ../../ttyUSB1

```

---

<div class="post-metadata">

### Author: ![sudomac](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sudomac](https://discourse.nodered.org/u/sudomac)
#### Post date: [12 October 2022 01:18 UTC](https://discourse.nodered.org/t/serial-permission-denied-dev-ttyusb0/68889/5 "2022-10-12T01:18:39Z")

</div>

How do I determine what user Node Red is using? Node Red doesn't start automagically. I start it after I log in as "joe". I assumed that Node Red is bound to the user that it starts under. At the moment, the Keyspan serial converter is the only serial device I use. It hasn't been a problem yet but noted. As for `ls -l /dev/serial/by-id/ `, it returns:

```auto
total 0
lrwxrwxrwx 1 root root 13 Oct 11 15:47 usb-Keyspan__a_division_of_InnoSys_Inc._Keyspan_USA-19H-if00-port0 -> ../../ttyUSB0

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [12 October 2022 06:48 UTC](https://discourse.nodered.org/t/serial-permission-denied-dev-ttyusb0/68889/6 "2022-10-12T06:48:41Z")

</div>

> [@sudomac](#):
>
> The same user "joe" can access the serial port using CuteCom, and Arduino IDE, seperatly of course!

Do you run CuteCom & Arduino IDE as root or via sudo?

Did you check `joe` was a member of `dialout`?  
What does `getent group dialout` show?

  

> [@sudomac](#):
>
> How do I determine what user Node Red is using

like that 👇

> [@TotallyInformation](#):
>
> So you may want to run a `top` command (I use `htop` personally) which should let you see which user owns the node-red process.

Using **htop**...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/f/9f4fc3444ac1570148a83e318c300c716ae8cf88.png)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [11 December 2022 06:49 UTC](https://discourse.nodered.org/t/serial-permission-denied-dev-ttyusb0/68889/7 "2022-12-11T06:49:04Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
