i have installed node-red system-wide on debian and can start with node-red-start on 1880.
The default folder installation is under /home/user/.node-red (hidden with dot).
also the service file is on /lib/systemd/system/nodered.service.
For duplication i have copy the folder .node-red to nodered1 to be used by extra instance nodered1 and the relative service file. then i change in settings.json the port from 1880 to 1881.
Then i have taken all the contents of this service file and try to replicate on another service file under:
sudo nano /etc/systemd/system/nodered1.service
The service is not starting probably because of wrong exec start.
anyone has experience with this issue ?
my end goal is to have node-red instance in a custom folder (for backup purposes) and manage this instance as a systemd service.
Does sudo systemctl status nodered1
give any useful indication of the problem? If not then try journalctl -u nodered1 --no-pager
[Edit]
You have not said, but I presume that you have started the service using sudo systemctl start nodered1
and if you want it to auto run on startup then sudo systemctl enable nodered1
You can check out my Alternate Node-RED Installer repo on GitHub. It contains a method for installing localised instances of Node-RED. It does not completely set up the systemd links but has a template you can adapt for yourself.
this command creates another user setup and running the instance on another port, which is partly what i need, but this is not running the instance as a service. needs manual start command.
this template i have used is from the original instance service located in /lib/systemd/system/nodered.service
[Unit]
Description=Node-RED 1 for ...
Wants=network.target
Documentation=http://nodered.org/docs/hardware/raspberrypi.html
[Service]
Type=simple
# Run as normal pi user - change to the user name you wish to run Node-RED as
User=user
Group=user
WorkingDirectory=/home/user/nodered1
Environment="NODE_OPTIONS=--max_old_space_size=2048"
# define an optional environment file in Node-RED's user directory to set custom variables ex>
EnvironmentFile=-/home/user/nodered1/environment
# uncomment and edit next line if you need an http proxy
#Environment="HTTP_PROXY=my.httpproxy.server.address"
# uncomment the next line for a more verbose log output
#Environment="NODE_RED_OPTIONS=-v"
# uncomment next line if you need to wait for time sync before starting
#ExecStartPre=/bin/bash -c '/bin/journalctl -b -u systemd-timesyncd | /bin/grep -q "systemd-t>
ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS
#ExecStart=/usr/bin/env node $NODE_OPTIONS red.js $NODE_RED_OPTIONS
# Use SIGINT to stop
KillSignal=SIGINT
# Auto restart on crash
Restart=on-failure
RestartSec=20
# Tag things in the log
SyslogIdentifier=Node-RED
#StandardOutput=syslog
[Install]
WantedBy=multi-user.target
This is the output:
Apr 16 15:28:30 dn-Rmg Node-RED[250640]: Welcome to Node-RED
Apr 16 15:28:30 dn-Rmg Node-RED[250640]: ===================
Apr 16 15:28:30 dn-Rmg Node-RED[250640]: 16 Apr 15:28:30 - [info] Node-RED version: v4.0.9
Apr 16 15:28:30 dn-Rmg Node-RED[250640]: 16 Apr 15:28:30 - [info] Node.js version: v20.18.3
Apr 16 15:28:30 dn-Rmg Node-RED[250640]: 16 Apr 15:28:30 - [info] Linux 6.1.0-30-amd64 x64 LE
Apr 16 15:28:31 dn-Rmg Node-RED[250640]: 16 Apr 15:28:31 - [info] Loading palette nodes
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: 16 Apr 15:28:32 - [info] Settings file : /home/user/.node-red/settings.js
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: 16 Apr 15:28:32 - [info] Context store : 'default' [module=memory]
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: 16 Apr 15:28:32 - [info] User directory : /home/user/.node-red
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: 16 Apr 15:28:32 - [warn] Projects disabled : editorTheme.projects.enabled=false
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: 16 Apr 15:28:32 - [info] Flows file : /home/user/.node-red/flows.json
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: 16 Apr 15:28:32 - [info] Creating new flow file
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: 16 Apr 15:28:32 - [warn]
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: ---------------------------------------------------------------------
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: Your flow credentials file is encrypted using a system-generated key.
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: If the system-generated key is lost for any reason, your credentials
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: file will not be recoverable, you will have to delete it and re-enter
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: your credentials.
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: You should set your own key using the 'credentialSecret' option in
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: your settings file. Node-RED will then re-encrypt your credentials
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: file using your chosen key the next time you deploy a change.
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: ---------------------------------------------------------------------
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: 16 Apr 15:28:32 - [warn] Encrypted credentials not found
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: 16 Apr 15:28:32 - [error] Unable to listen on http://127.0.0.1:1880/
Apr 16 15:28:32 dn-Rmg Node-RED[250640]: 16 Apr 15:28:32 - [error] Error: port in use
Apr 16 15:28:54 dn-Rmg Node-RED[250732]: 16 Apr 15:28:54 - [info]
it still uses the port 1880, even if i go to settings.js of the folder and change it.
in folder nodered1 / settings.js:
uiPort: process.env.PORT || 1881.
Thanks for sharing! I’ve done something similar—make sure ExecStart points to the correct Node-RED binary. Try using which node-red or which node-red-pi to confirm the right path. Also, check permissions and environment file existence. Good luck!