running node red as root

3,388 views
Skip to first unread message

Son Huynh

unread,
Mar 28, 2017, 1:57:02 PM3/28/17
to Node-RED
I was wondering about node red. I usually access node red by clicking Programming>>Node-Red. If I edit the properties of the icon and change it to sudo su start node-red. Will that be considered as running it as root? Reason I'm asking is because I'm trying to run raspi-io and it needs to be ran as node-red. Thanks

Son Huynh

unread,
Mar 28, 2017, 1:58:16 PM3/28/17
to Node-RED
....raspi-io and it needs to be ran as root**

Julian Knight

unread,
Mar 28, 2017, 5:47:14 PM3/28/17
to Node-RED
I really wish they would fix that, there is no real excuse for forcing people to run as root.

Son Huynh

unread,
Mar 28, 2017, 5:50:05 PM3/28/17
to Node-RED
how do i run the raspi-io module as root?

Dave C-J

unread,
Mar 28, 2017, 6:00:06 PM3/28/17
to node...@googlegroups.com
What is the end goal ? There may be other ways or modules that could help, instead of raspi.io


Mark Setrem

unread,
Mar 28, 2017, 6:03:43 PM3/28/17
to Node-RED
You don't run it as root directly.  

It is a plugin for node-red-contrib-gpio, but to use it you do correctly appear to have to run node-red as root but YES sudo is good enough.

Make sure you have also installed wiring-pi  (sudo apt-get install wiringpi)
and install johnny-five and raspi-io into your .node-red directory WITHOUT using sudo  ( npm install johnny-five raspi-io ) (

Son Huynh

unread,
Mar 28, 2017, 6:38:51 PM3/28/17
to Node-RED
I keep getting the following error even though i used sudo start-node-red and it keeps looping:

Started Node-RED graphical event wiring tool..
28 Mar 00:20:21 - [info]
Welcome to Node-RED

28 Mar 00:20:21 - [info] Node-RED version: v0.16.2
28 Mar 00:20:21 - [info] Node.js version: v6.10.1
28 Mar 00:20:21 - [info] Linux 4.4.50-v7+ arm LE
28 Mar 00:20:23 - [info] Loading palette nodes
pi : TTY=unknown ; PWD=/home/pi ; USER=root ; COMMAND=/usr/bin/python -u /usr/lib/node_modules/node-red/nodes/core/hardware/nrgpio.py info
pam_unix(sudo:session): session opened for user root by (uid=0)
pam_unix(sudo:session): session closed for user root
28 Mar 00:20:30 - [info] Dashboard version 2.3.6 started at /ui
28 Mar 00:20:37 - [info] Settings file : /home/pi/.node-red/settings.js
28 Mar 00:20:37 - [info] User directory : /home/pi/.node-red
28 Mar 00:20:37 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
28 Mar 00:20:37 - [info] Server now running at http://127.0.0.1:1880/
28 Mar 00:20:37 - [info] Starting flows
1490678437632 Device(s) RaspberryPi-IO
1490678437663 Device(s) RaspberryPi-IO
1490678437688 Device(s) RaspberryPi-IO
1490678437713 Device(s) RaspberryPi-IO
28 Mar 00:20:37 - [info] Started flows
28 Mar 00:20:37 - [red] Uncaught Exception:
28 Mar 00:20:37 - Error: EACCES: permission denied, open '/sys/class/leds/led0/trigger'
at Error (native)
at Object.fs.openSync (fs.js:641:18)
at Object.fs.writeFileSync (fs.js:1347:33)
at new LED (/home/pi/.node-red/node_modules/raspi-led/dist/index.js:42:18)
at RaspiIOCore.value (/home/pi/.node-red/node_modules/raspi-io-core/dist/index.js:525:34)
at RaspiIOCore.pinMode (/home/pi/.node-red/node_modules/raspi-io-core/dist/index.js:484:21)
at /home/pi/.node-red/node_modules/raspi-io-core/dist/index.js:408:17
at Array.forEach (native)
at /home/pi/.node-red/node_modules/raspi-io-core/dist/index.js:337:32
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
nodered.service: main process exited, code=exited, status=1/FAILURE
Unit nodered.service entered failed state.
nodered.service holdoff time over, scheduling restart.
Stopping Node-RED graphical event wiring tool....
Starting Node-RED graphical event wiring tool....
Started Node-RED graphical event wiring tool..
28 Mar 00:20:40 - [info]

Son Huynh

unread,
Mar 28, 2017, 9:39:45 PM3/28/17
to Node-RED
@Dave, I just needed to get raw data out from an MPU6050 accelerometer for the raspberry pi 3 version B. I imported a flow from node red palette called "Read an i2c-based mpu6050 accelerometer on a raspberry pi"

Mark Setrem

unread,
Mar 29, 2017, 2:26:16 AM3/29/17
to Node-RED
Have you turned on i2c in raspi-config?

Son Huynh

unread,
Mar 29, 2017, 9:04:57 AM3/29/17
to Node-RED
yes :/

Son Huynh

unread,
Mar 29, 2017, 1:55:08 PM3/29/17
to Node-RED
this is me running it as root but still getting same error

pi@raspberrypi:~ $ sudo su
root@raspberrypi:/home/pi# node-red-start

Start Node-RED
 
Once Node-RED has started, point a browser at http://10.0.0.13:1880
On Pi Node-RED works better with the Firefox browser
 
Use   node-red-stop                          to stop Node-RED
Use   node-red-start                         to start Node-RED again
Use   node-red-log                           to view the recent log output
Use   sudo systemctl enable nodered.service  to autostart Node-RED at every boot
Use   sudo systemctl disable nodered.service to disable autostart on boot
 
To find more nodes and example flows - go to http://flows.nodered.org
 
Started Node-RED graphical event wiring tool..
29 Mar 12:53:06 - [info]
Welcome to Node-RED
===================
29 Mar 12:53:06 - [info] Node-RED version: v0.16.2
29 Mar 12:53:06 - [info] Node.js  version: v6.10.1
29 Mar 12:53:06 - [info] Linux 4.4.50-v7+ arm LE
29 Mar 12:53:08 - [info] Loading palette nodes
pi : TTY=unknown ; PWD=/home/pi ; USER=root ; COMMAND=/usr/bin/python -u /usr/lib/node_modules/node-red/nodes/core/hardware/nrgpio.py info
pam_unix(sudo:session): session opened for user root by (uid=0)
pam_unix(sudo:session): session closed for user root
29 Mar 12:53:14 - [info] Dashboard version 2.3.6 started at /ui
29 Mar 12:53:18 - [info] Settings file  : /home/pi/.node-red/settings.js
29 Mar 12:53:18 - [info] User directory : /home/pi/.node-red
29 Mar 12:53:18 - [info] Flows file     : /home/pi/.node-red/flows_raspberrypi.json
29 Mar 12:53:18 - [info] Server now running at http://127.0.0.1:1880/
29 Mar 12:53:18 - [info] Starting flows
1490809998704 Device(s) RaspberryPi-IO
1490809998738 Device(s) RaspberryPi-IO
1490809998762 Device(s) RaspberryPi-IO
1490809998808 Device(s) RaspberryPi-IO
29 Mar 12:53:18 - [info] Started flows
29 Mar 12:53:18 - [red] Uncaught Exception:
29 Mar 12:53:18 - Error: EACCES: permission denied, open '/sys/class/leds/led0/trigger'
at Error (native)
at Object.fs.openSync (fs.js:641:18)
at Object.fs.writeFileSync (fs.js:1347:33)
at new LED (/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/raspi-led/dist/index.js:42:18)
at RaspiIOCore.value (/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/raspi-io-core/dist/index.js:525:34)
at RaspiIOCore.pinMode (/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/raspi-io-core/dist/index.js:484:21)
at /home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/raspi-io-core/dist/index.js:408:17
at Array.forEach (native)
at /home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/raspi-io-core/dist/index.js:337:32
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
nodered.service: main process exited, code=exited, status=1/FAILURE
Unit nodered.service entered failed state.
nodered.service holdoff time over, scheduling restart.
Stopping Node-RED graphical event wiring tool....
Starting Node-RED graphical event wiring tool....
Started Node-RED graphical event wiring tool..
29 Mar 12:53:21 - [info]

On Wednesday, March 29, 2017 at 1:26:16 AM UTC-5, Mark Setrem wrote:

Julian Knight

unread,
Mar 30, 2017, 4:07:03 AM3/30/17
to Node-RED
From a command line, can you run the following:

sudo ls -l /sys/class/leds/led0/trigger

And report back the results.

Son Huynh

unread,
Mar 30, 2017, 6:25:28 PM3/30/17
to Node-RED
this is what I get:

-rw-r--r-- 1 root root 4096 Mar 30 17:22 /sys/class/leds/led0/trigger


I've also been trying a few things, I'm not sure if it affected my problem:

sudo -s
echo heartbeat >/sys/class/leds/led0/trigger

and also

echo heartbeat | sudo tee /sys/class/leds/led0/trigger >/dev/null

and

sudo sh -c "echo heartbeat >/sys/class/leds/led0/trigger"

Colin Law

unread,
Mar 31, 2017, 3:43:10 AM3/31/17
to node...@googlegroups.com
Looking at node-red-start I see that it starts node red using
sudo service nodered start
Does that mean that it will actually use the systemctl service /lib/systemd/system/nodered.service to start node red? If that is the case then it will set the user to that specified in that service (which will be the user pi by default) so using sudo with node-red-start will not have any effect.

Colin

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/9171407d-6929-4de1-9c44-6a176bbe4c10%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Julian Knight

unread,
Mar 31, 2017, 9:33:55 AM3/31/17
to Node-RED
Ah, good spot Colin.

Son Huynh

unread,
Mar 31, 2017, 12:25:05 PM3/31/17
to Node-RED
so do i just do sudo nano /lib/systemd/system/nodered.service and change user to root? will that solve the problem?

Mark Setrem

unread,
Mar 31, 2017, 12:45:04 PM3/31/17
to Node-RED
Personally i would
1) Stop the service running
2) Try running node-red as root from the command line
3)When you are sure it is working, then think about re-enabling running node-red as a service

Son Huynh

unread,
Mar 31, 2017, 3:18:23 PM3/31/17
to Node-RED
how would i go about doing this?

Mark Setrem

unread,
Mar 31, 2017, 3:47:44 PM3/31/17
to Node-RED

Son Huynh

unread,
Apr 3, 2017, 12:10:43 AM4/3/17
to Node-RED
i decided to just run node-red as root to simplify all the problems :/

Colin Law

unread,
Apr 3, 2017, 3:43:59 AM4/3/17
to node...@googlegroups.com
On 31 March 2017 at 17:25, Son Huynh <ghuyn...@gmail.com> wrote:
so do i just do sudo nano /lib/systemd/system/nodered.service and change user to root? will that solve the problem?

If you do another upgrade-nodejs-and-nodered it will restore the user to the default so you would have to edit it again.

Colin
 

On Friday, March 31, 2017 at 8:33:55 AM UTC-5, Julian Knight wrote:
Ah, good spot Colin.

On Friday, 31 March 2017 08:43:10 UTC+1, Colin Law wrote:
Looking at node-red-start I see that it starts node red using
sudo service nodered start
Does that mean that it will actually use the systemctl service /lib/systemd/system/nodered.service to start node red? If that is the case then it will set the user to that specified in that service (which will be the user pi by default) so using sudo with node-red-start will not have any effect.

Colin

On 29 March 2017 at 18:55, Son Huynh <ghuyn...@gmail.com> wrote:
this is me running it as root but still getting same error

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Son Huynh

unread,
Apr 3, 2017, 10:10:25 AM4/3/17
to Node-RED
oooo good to know, thank you everyone for helping with this. I got it node-red working again, butt the flow I'm using is not working lol. oh well, onto the next problem.


On Monday, April 3, 2017 at 2:43:59 AM UTC-5, Colin Law wrote:
On 31 March 2017 at 17:25, Son Huynh <ghuyn...@gmail.com> wrote:
so do i just do sudo nano /lib/systemd/system/nodered.service and change user to root? will that solve the problem?

If you do another upgrade-nodejs-and-nodered it will restore the user to the default so you would have to edit it again.

Colin
 

On Friday, March 31, 2017 at 8:33:55 AM UTC-5, Julian Knight wrote:
Ah, good spot Colin.

On Friday, 31 March 2017 08:43:10 UTC+1, Colin Law wrote:
Looking at node-red-start I see that it starts node red using
sudo service nodered start
Does that mean that it will actually use the systemctl service /lib/systemd/system/nodered.service to start node red? If that is the case then it will set the user to that specified in that service (which will be the user pi by default) so using sudo with node-red-start will not have any effect.

Colin

On 29 March 2017 at 18:55, Son Huynh <ghuyn...@gmail.com> wrote:
this is me running it as root but still getting same error

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
Reply all
Reply to author
Forward
0 new messages