Unable to start Node-red upon boot

ohh...
This is whats on mine.....:frowning:

node-reg-log.....nothing!
image

What does node-red-start show. That should start it with systemd and then show the startup messages

Odd, post here /lib/systemd/system/nodered.service I suspect there is an issue there. Can you copy/paste logs and file contents rather than screenshot, it is much easier to deal with? Thanks.

[Edit] Also what do
ls -l /usr/bin/env
and
which env
show?

I have the script on the below path

/etc/systemd/system/node-red.servic

I added the .txt to the end
node-red.service.txt (380 Bytes)


indika@WEERAServer:~$ node-red-start

Start Node-RED

Once Node-RED has started, point a browser at http://192.168.0.96:1880
On Pi Node-RED works better with the Firefox or Chrome 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
[sudo] password for indika:

Starting as a systemd service.
nodered.service: Service hold-off time over, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 1.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
nodered.service: Failed to determine user credentials: No such process
nodered.service: Failed at step USER spawning /usr/bin/env: No such process
nodered.service: Main process exited, code=exited, status=217/USER
nodered.service: Failed with result 'exit-code'.
nodered.service: Service hold-off time over, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 2.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
nodered.service: Failed to determine user credentials: No such process
nodered.service: Failed at step USER spawning /usr/bin/env: No such process
nodered.service: Main process exited, code=exited, status=217/USER
nodered.service: Failed with result 'exit-code'.
nodered.service: Service hold-off time over, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 3.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
nodered.service: Failed to determine user credentials: No such process
nodered.service: Failed at step USER spawning /usr/bin/env: No such process
nodered.service: Main process exited, code=exited, status=217/USER
nodered.service: Failed with result 'exit-code'.
nodered.service: Service hold-off time over, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 4.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
nodered.service: Failed to determine user credentials: No such process
nodered.service: Failed at step USER spawning /usr/bin/env: No such process
nodered.service: Main process exited, code=exited, status=217/USER
nodered.service: Failed with result 'exit-code'.
nodered.service: Service hold-off time over, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 5.
Stopped Node-RED graphical event wiring tool.
nodered.service: Start request repeated too quickly.
nodered.service: Failed with result 'exit-code'.
Failed to start Node-RED graphical event wiring tool.


indika@WEERAServer:~$ sudo systemctl status nodered

[sudo] password for indika:
● nodered.service - Node-RED graphical event wiring tool
Loaded: loaded (/lib/systemd/system/nodered.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2019-10-31 12:55:58 EDT; 45min ago
Docs: Redirecting…
Process: 1362 ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS (code=exited, status=217/USER)
Main PID: 1362 (code=exited, status=217/USER)

Oct 31 12:55:58 WEERAServer systemd[1]: nodered.service: Service hold-off time over, scheduling restart.
Oct 31 12:55:58 WEERAServer systemd[1]: nodered.service: Scheduled restart job, restart counter is at 5.
Oct 31 12:55:58 WEERAServer systemd[1]: Stopped Node-RED graphical event wiring tool.
Oct 31 12:55:58 WEERAServer systemd[1]: nodered.service: Start request repeated too quickly.
Oct 31 12:55:58 WEERAServer systemd[1]: nodered.service: Failed with result 'exit-code'.
Oct 31 12:55:58 WEERAServer systemd[1]: Failed to start Node-RED graphical event wiring tool.
indika@WEERAServer:~$


indika@WEERAServer:~$ node-red

31 Oct 13:43:31 - [info]

Welcome to Node-RED

31 Oct 13:43:31 - [info] Node-RED version: v1.0.2
31 Oct 13:43:31 - [info] Node.js version: v8.10.0
31 Oct 13:43:31 - [info] Linux 4.15.0-66-generic x64 LE
31 Oct 13:43:33 - [info] Loading palette nodes
31 Oct 13:43:43 - [info] Settings file : /home/indika/.node-red/settings.js
31 Oct 13:43:43 - [info] Context store : 'default' [module=memory]
31 Oct 13:43:43 - [info] User directory : /home/indika/.node-red
31 Oct 13:43:43 - [warn] Projects disabled : editorTheme.projects.enabled=false
31 Oct 13:43:43 - [info] Flows file : /home/indika/.node-red/flows_WEERAServer.json
31 Oct 13:43:43 - [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.

31 Oct 13:43:43 - [info] Starting flows
31 Oct 13:43:43 - [info] Started flows
31 Oct 13:43:43 - [info] Server now running at http://127.0.0.1:1880/

That is not the right service file. Look at the systemd status output and you will see it is where I suggested. Also the one you have posted is node-red.service, whereas the correct one is nodered.service.
Sorry, I didn't mean you to repost all the stuff you had already posted, I just meant for the future, the systemd script for example. I you click the </> button above the edit box when posting and paste the text there it will stop the forum from reformatting it.

Also what do
ls -l /usr/bin/env
and
which env
show?

indika@WEERAServer:~$ ls -l /usr/bin/env
-rwxr-xr-x 1 root root 35000 Jan 18  2018 /usr/bin/env
indika@WEERAServer:~$ which env
/usr/bin/env
indika@WEERAServer:~$

Also make sure you systemctl disable node-red or it will be trying to run that one on boot as well as nodered.service.

Well env looks alright, so I think it is back to the systemd script, if you can find the right one. It must be there as systemd status found it.

found it under "/lib/systemd/system/"
nodered.service.txt (917 Bytes)

Thanks

[edit]
YES....that's it...
everything is working as soon as I change the user & group to "indika".....

Thanks u so much Colin and everyone.

....can not reply my daily limit is over....

Below is the log /var/log/nodered-install.log

***************************************

Started : Thu Oct 31 00:01:23 EDT 2019
Running for user indika at /home/indika
Failed to stop nodered.service: Unit nodered.service not loaded.
Found global nodes:   :

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package nodered
Now install nodejs
Updating nodejs v0
Not using nodesource.list

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
Package 'nodejs-legacy' is not installed, so not removed
Package 'npm' is not installed, so not removed
Package 'nodejs' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
dpkg: warning: ignoring request to remove nodejs which isn't installed
dpkg: warning: ignoring request to remove node which isn't installed

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
Grab the LTS bundle

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Hit:1 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Err:4 http://plex.r.worldssl.net/PlexMediaServer/ubuntu-repo lucid InRelease
  Could not resolve 'plex.r.worldssl.net'
Get:5 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Fetched 252 kB in 2s (150 kB/s)
Reading package lists...
Building dependency tree...
Reading state information...
15 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: Failed to fetch http://plex.r.worldssl.net/PlexMediaServer/ubuntu-repo/dists/lucid/InRelease  Could not resolve 'plex.r.worldssl.net'
W: Some index files failed to download. They have been ignored, or old ones used instead.

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...

Well that is very odd, the install script has not put your user name in the script. I presume you were logged in as your normal user when you ran the script, and didn't use sudo. Whatever, to fix it edit that file and change the user and group from pi to your user name (indika). Then so that systemd will reload it
sudo systemctl daemon-reload
then
node-red-start
Assuming that fixes it I would like to understand what went wrong. Can you post the install log please, /var/log/nodered-install.log

[Edit] Oh, change the Working Directory too.

I don't think that is the whole log.

By the way, see this for installing plexmediaserver, you have an out of date repository specified. Go down a bit to where it shows how to enable the official repository.

I have looked at the install script and can't see how it didn't setup the script correctly, so would be grateful if you could post the full install log when convenient.
Thanks.

Log file....
nodered-install.log.txt (3.6 KB)

My Plex server is up to date. But I will take a look at the link you posted.
image

Thank you for your help.

That cannot be the whole of the log, it has not even got as far as installing nodejs.

Use one of methods to run the task at start up. i tried rc.local. you can execute it manually and verify. initial faced same issues.

sudo nano /lib/systemd/system/nodered.service
Replace
Environment="NODE_OPTIONS=--max_old_space_size=256"
with

Environment="NODE_OPTIONS=--max-old-space-size=256"

Worked for me.

hmmm I've just tried to upgrade node-red using the original script I used to install and now starting from the service fails, but I can get it to run if I run node-red-start.

I used the script

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

root@raspbx:~# sudo systemctl status nodered
● nodered.service - Node-RED graphical event wiring tool
   Loaded: loaded (/lib/systemd/system/nodered.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2020-05-31 23:59:18 BST; 6min ago
     Docs: http://nodered.org/docs/hardware/raspberrypi.html
 Main PID: 435 (code=exited, status=127)

May 31 23:59:17 raspbx systemd[1]: nodered.service: Failed with result 'exit-code'.
May 31 23:59:18 raspbx systemd[1]: nodered.service: Service hold-off time over, scheduling restart.
May 31 23:59:18 raspbx systemd[1]: Stopped Node-RED graphical event wiring tool.
May 31 23:59:18 raspbx systemd[1]: nodered.service: Start request repeated too quickly.
May 31 23:59:18 raspbx systemd[1]: Failed to start Node-RED graphical event wiring tool.
May 31 23:59:18 raspbx systemd[1]: nodered.service: Unit entered failed state.
May 31 23:59:18 raspbx systemd[1]: nodered.service: Failed with result 'exit-code'.

/usr/bin/env: ‘node-red-pi’: No such file or directory

Also this " node-red-start - this starts the Node-RED service and displays its log output. Pressing Ctrl-C or closing the window does not stop the service; it keeps running in the background"

simply isn't true - pressing ctrl-c or closing the Window DOES stop the service on my install. I wish I hadn't tried to upgrade, the script has totally broken a working installation!

Can you show us the log from when you run the script ? And also a log of when you just run the node-red command

--------> Error log. <-------

node-red-log:

Started Node-RED graphical event wiring tool.

Node-RED is not yet fully installed
   Can't reach upgrade server - please check your internet connection.

whereas node-red-start starts the app within that terminal window, as soon as I close it or ctrl-c it stops again.

Welcome to Node-RED
===================

1 Jun 07:46:13 - [info] Node-RED version: v1.0.6
1 Jun 07:46:13 - [info] Node.js  version: v12.15.0
1 Jun 07:46:13 - [info] Linux 4.19.57-v7+ arm LE
1 Jun 07:46:14 - [info] Loading palette nodes
1 Jun 07:46:16 - [warn] ------------------------------------------------------
1 Jun 07:46:16 - [warn] [node-red-node-serialport/serialport] Error: The module '/root/.node-red/node_modules/@serialport/bindings/build/Release/bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 72. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
1 Jun 07:46:16 - [warn] ------------------------------------------------------
1 Jun 07:46:16 - [info] Settings file  : /root/.node-red/settings.js
1 Jun 07:46:16 - [info] Context store  : 'default' [module=memory]
1 Jun 07:46:16 - [info] User directory : /root/.node-red
1 Jun 07:46:16 - [warn] Projects disabled : editorTheme.projects.enabled=false
1 Jun 07:46:16 - [info] Flows file     : /root/.node-red/flows_raspbx.json
1 Jun 07:46:16 - [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.
---------------------------------------------------------------------

1 Jun 07:46:16 - [info] Starting flows
1 Jun 07:46:17 - [info] Started flows
1 Jun 07:46:17 - [info] Server now running at http://127.0.0.1:1880/
1 Jun 07:46:17 - [info] [mqtt-broker:34ac2466.a0f64c] Connected to broker: node-red@mqtt://192.168.0.110:1883

--------> Error log. <-------