Node-RED won't run as service Debian 10

Hello all, I installed Node-RED using the script, as I try to set it up to run as service I got an error.

If you run node-red-start it will start it using the service but then the log will appear. Alternatively you can look back in /var/log/syslog to the time 12:39 and you will see it there.

Tip: node-red-log will just display that same tail of the log, and keep it updated as more comes in. However, since you're coming from a crashed state, node-red-start is the better option here. For future reference though :slight_smile:

sudo journalctl nodered will show you the last few lines of the log, adding the -f (follow) parameter will keep the log showing.

I recommend starting another terminal window to show the log in realtime - that way you can see exactly what is happening.

I've just gone through all this on my new build - though I use my own service file with my alternate installer.

That's what node-red-log does.

Ah, well I prefer to use native commands where possible - that way I also know how to show the logs for mosquitto, InfluxDB, Grafana, Telegraf, ... :grinning:

I guess I just like to know how things work!

Has anyone solved this error before?

Can you post here the service file /lib/systemd/system/nodered.service please. Copy/paste if possible rather than a screenshot, it is easier to read.
Did you run the install script as root by any chance? You should have run it logged in as the user you want to run node-red (which should not be root). If you did run it as root then I think you can just edit the service file and change the user, group and working directory. then run the sudo systemctl daemon-reload and try starting node-red again.

1 Like

For reference, here is my custom service file on my new build:

# A TEMPLATE systemd service file for running Node-RED
# CHANGE the settings before use.
# See
# This file must be linked into the /etc/systemd/system/ folder:
#    1) Rename this file to have a unique name (in case you want other instances running)
#    2) sudo /bin/systemctl enable /home/<user>/<folder>/system/<filename>.service
#    3) sudo systemctl daemon-reload
# After installing or changing this file:
#    1) sudo systemctl daemon-reload
# Start manually with `sudo /bin/systemctl start <filename>`
# View logs with `sudo journalctl -u <filename>` (e.g. `sudo journalctl -u node-red`)
# View service status with `sudo systemctl status <filename>`

Description=Knightnet Home Automation System - Node-RED nrmain
# Syslog and Networking must be active before starting
# Mosquitto (MQTT) & InfluxDB may be wanted - ADJUST to need
Wants=mosquitto.service influxdb.service


# -- Set any required environment variables - ADJUST these according to your installation --
Environment="NODE_RED_OPTIONS=--userDir /home/home/nrmain/data -v"
Environment="NODE_OPTIONS= "

# Or use an environment variables file, overrides the Environment settings
# makes it nice and easy to change without having to edit this file.
# Ignored if file does not exist. Entries in file overwrite those above.
# @See

# No path environment variable is yet available here so make sure absolute folders specified
ExecStart=/usr/bin/node $NODE_OPTIONS /home/home/nrmain/node_modules/node-red/red.js $NODE_RED_OPTIONS


# User/Group that launches node-RED (it's advised to create a new user for Node-RED)
# You can do : sudo useradd node-red then change the User=pi to User=node-red
# If changing the user/group, make sure that ALL FILES and FOLDERS have the correct
# ownership before continuing.



# Make Node-RED restart if it fails


# Node-RED needs a SIGINT to be notified to stop

# Prevent this service changing the OS or /etc
# @See

# PID file

1 Like

Is that path correct? I see it repeated over the other variables so I think it is, although an unusual name it would make sense, but it can lead to confusion :slight_smile:

Yes, correct. My own fault for choosing a default user name to match the purpose of the device! :scream_cat:

Only me directly using the device though so not really an issue.

This is what the standard Debian/pi install script installs (unless it has changed recently)

# systemd service file to start Node-RED

Description=Node-RED graphical event wiring tool

# Run as normal pi user - change to the user name you wish to run Node-RED as

# uncomment and edit next line if you need an http proxy
# uncomment the next line for a more verbose log output
#ExecStart=/usr/bin/env node $NODE_OPTIONS red.js $NODE_RED_OPTIONS
ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS
# Use SIGINT to stop
# Auto restart on crash
# Tag things in the log


Apart from running from a local install of Node-RED instead of a global one, the main difference in mine is the ability to override the environment vars and therefore the startup settings via a local file. It also requires syslog & networking along with Mosquitto and InfluxDB to be started first. Also I don't set max-old-space by default (because this was taken from the laptop build). Not sure if ProtectSystem=full actually does anything in this case but it seemed sensible.

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