"sudo systemctl enable nodered.service" in ubuntu fail?

Hello all , follow the instruction by "https://nodered.org/docs/getting-started/raspberrypi".
I have run:

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodere
sudo systemctl enable nodered.service

but failed .
The log :

ubuntu 16.04
npm 6.9.0
node-red v10.16.3

I have searched for some similar issue in forum,but still can not find a solution.
Is there any suggestion ?
Thanks.

As the error says, you should check the permissions on the file /home/gaofei/.node-red/settings.js.

Thanks, the setting.js is a default configuration.
Do I have to change it ?

Normally it all just works. But in this instance something has gone wrong with the permissions and it is preventing Node-RED from reading your settings file.

Had you run node-red manually before starting it as a service?

Can you share the output of the command:

ls -la /home/gaofei/.node-red/settings.js

Yes I can run it successfully with command " node-red" .

by the way ,I have check the /lib/systemd/system/ nodered.service and confirm that the user is "gaofei" .
Thanks for your reply.

That is odd. You say you have run systemctl enable, but did you restart node-red (enable just tells it to run on boot). In a terminal run

node-red-stop
node-red-start

and post the full log.
If still getting the error also post nodered.service

If close the window ,the service do not keep running in the background.

I find a similar topic in Unhandled rejection Error: EACCES: permission denied,.

sudo apt-get purge nodejs
bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

also no effect.

Thanks.

hi @gaofei207, there's a snap version you could try out. :slightly_smiling_face:

I don't advise using the snap, the pi install script should do it. What does
sudo systemctl status nodered
show? Then run

sudo systemctl restart nodered
node-red-log

And post the result. Please copy/paste rather than screen shot, it makes it easier to access.

Edit - I have corrected the restart command above, there was a typo

1 Like

gaofei@iZbp1fazljd8u3jfbtht09Z:~$ sudo systemctl status nodered
[sudo] password for gaofei:
â—Ź nodered.service - Node-RED graphical event wiring tool
Loaded: loaded (/lib/systemd/system/nodered.service; enabled; vendor preset: enabled)
Active: inactive (dead)
Docs: http://nodered.org/docs/hardware/raspberrypi.html

Oct 10 21:03:31 iZbp1fazljd8u3jfbtht09Z systemd[1]: nodered.service: Start request repeated too quickly.
Oct 10 21:03:31 iZbp1fazljd8u3jfbtht09Z systemd[1]: Failed to start Node-RED graphical event wiring tool.
Oct 10 21:45:40 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.
Oct 10 21:54:46 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.
Oct 10 21:54:51 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.
Oct 10 21:55:38 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.
Oct 10 22:45:06 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.
Oct 11 08:33:05 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.
Oct 11 08:33:07 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.
Oct 11 08:35:37 iZbp1fazljd8u3jfbtht09Z systemd[1]: Stopped Node-RED graphical event wiring tool.
gaofei@iZbp1fazljd8u3jfbtht09Z:~ ^C gaofei@iZbp1fazljd8u3jfbtht09Z:~ sudo systemctl restart nodered
gaofei@iZbp1fazljd8u3jfbtht09Z:~$ node-red-log

===================
11 Oct 14:57:58 - [info] Node-RED version: v1.0.1
11 Oct 14:57:58 - [info] Node.js version: v10.16.3
11 Oct 14:57:58 - [info] Linux 4.4.0-105-generic x64 LE
11 Oct 14:57:59 - [info] Loading palette nodes
11 Oct 14:57:59 - [warn] rpi-gpio : Raspberry Pi specific node set inactive
11 Oct 14:57:59 - [info] Settings file : /home/gaofei/.node-red/settings.js
11 Oct 14:57:59 - [info] Context store : 'default' [module=memory]
11 Oct 14:57:59 - [info] User directory : /home/gaofei/.node-red
11 Oct 14:57:59 - [warn] Projects disabled : editorTheme.projects.enabled=false
11 Oct 14:57:59 - [info] Flows file : /home/gaofei/.node-red/flows_iZbp1fazljd8u3jfbtht09Z.json
11 Oct 14:57:59 - [info] Creating new flow file
11 Oct 14:57:59 - [warn]

Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

11 Oct 14:57:59 - [info] Starting flows
11 Oct 14:57:59 - [info] Started flows
11 Oct 14:57:59 - [info] Server now running at http://127.0.0.1:1880/

It seems works . If close the window ,the service still run.
Thanks.

There is something not right as node-red-start should have done the same thing. Are you in the group sudo? Run the command groups to find out. If it does not show sudo then that is the explanation. If it does show sudo then what does which node-red-start show? If that is /usr/bin/node-red-start then could you post the contents of that here?

gaofei@iZbp1fazljd8u3jfbtht09Z:~ sudo groups root gaofei@iZbp1fazljd8u3jfbtht09Z:~ groups
gaofei
gaofei@iZbp1fazljd8u3jfbtht09Z:~$

I have add user 'gaofei' sudo permission.
Now it works.

gaofei@iZbp1fazljd8u3jfbtht09Z:~$ sudo systemctl status nodered
â—Ź nodered.service - Node-RED graphical event wiring tool
Loaded: loaded (/lib/systemd/system/nodered.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-10-11 16:41:42 CST; 15s ago
Docs: http://nodered.org/docs/hardware/raspberrypi.html
Main PID: 29654 (node-red)
CGroup: /system.slice/nodered.service
└─29654 node-red

Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: If the system-generated key is lost for any reason, your credentials
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: file will not be recoverable, you will have to delete it and re-enter
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: your credentials.
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: You should set your own key using the 'credentialSecret' option in
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: your settings file. Node-RED will then re-encrypt your credentials
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: file using your chosen key the next time you deploy a change.
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: ---------------------------------------------------------------------
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: 11 Oct 16:41:43 - [info] Starting flows
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: 11 Oct 16:41:43 - [info] Started flows
Oct 11 16:41:43 iZbp1fazljd8u3jfbtht09Z Node-RED[29654]: 11 Oct 16:41:43 - [info] Server now running at http://127.0.0.1:1880/

Thanks for your great help.:grinning:

Check that

node-red-stop
node-red-start

now says it is starting it using systemd and it does not close when you break out. Then all is well.

It is all right now. Thanks for your kindly help.