Serial permission denied /dev/ttyUSB0

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?

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

@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!

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.

$ 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

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:

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

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?


like that :point_down:

Using htop ...

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