# Run node-red instance as a service with dedicated folder

**URL:** <https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602>\
**Category:** General\
**Created:** [16 April 2025 09:41 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602 "2025-04-16T09:41:01Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![BambosD](https://avatars.discourse-cdn.com/v4/letter/b/54ee81/32.png) [@BambosD](https://discourse.nodered.org/u/BambosD)\
**Post date:** [16 April 2025 09:41 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/1 "2025-04-16T09:41:01Z")

</div>

Hello everyone,

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

changes:  
WorkingDirectory=/home/user/.node-red  
WorkingDirectory=/home/user/nodered1

EnvironmentFile=-/home/user/.node-red/environment  
EnvironmentFile=-/home/user/nodered1/environment

ExecStart=/usr/bin/env node-red-pi $NODE\_OPTIONS $NODE\_RED\_OPTIONS

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.

any suggestions appreciated.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 April 2025 09:58 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/2 "2025-04-16T09:58:52Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [16 April 2025 10:38 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/3 "2025-04-16T10:38:14Z")

</div>

You can check out my [Alternate Node-RED Installer repo on GitHub](https://github.com/TotallyInformation/alternate-node-red-installer). 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.

---

<div class="post-metadata">

**Author:** ![BambosD](https://avatars.discourse-cdn.com/v4/letter/b/54ee81/32.png) [@BambosD](https://discourse.nodered.org/u/BambosD)\
**Post date:** [16 April 2025 12:17 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/4 "2025-04-16T12:17:06Z")

</div>

> [@Colin](#):
>
> ``  
> and if you want it to auto run on startup then

Hello, yes i see that the instance still using parts of the default instance, like below:

16 Apr 15:13:47 - [info] Settings file : /home/user/.node-red/settings.js  
Apr 16 15:13:47 dn-Rmg Node-RED[247536]: 16 Apr 15:13:47 - [info] Context store : 'default' [module=memory]  
Apr 16 15:13:47 dn-Rmg Node-RED[247536]: 16 Apr 15:13:47 - [info] User directory : /home/user/.node-red

yes, i have enable and start the service normally like using systemd

in parallel i'm searching more for how to do this, and found this article using different users instance. [Local Installs and Managing Node-Red Projects - Steves Node-Red Guide](https://stevesnoderedguide.com/managing-node-red-projects)

node-red -u user1 -p 1882

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 April 2025 12:25 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/5 "2025-04-16T12:25:05Z")

</div>

Can you post your systemd script please and the output from the journalctl command

---

<div class="post-metadata">

**Author:** ![BambosD](https://avatars.discourse-cdn.com/v4/letter/b/54ee81/32.png) [@BambosD](https://discourse.nodered.org/u/BambosD)\
**Post date:** [16 April 2025 12:25 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/6 "2025-04-16T12:25:44Z")

</div>

thank you, i will keep this as an option.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 April 2025 12:28 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/7 "2025-04-16T12:28:39Z")

</div>

Also, did you run  
`sudo systemctl daemon-reload`  
or reboot each time you edit the systemd script?

---

<div class="post-metadata">

**Author:** ![BambosD](https://avatars.discourse-cdn.com/v4/letter/b/54ee81/32.png) [@BambosD](https://discourse.nodered.org/u/BambosD)\
**Post date:** [16 April 2025 12:31 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/8 "2025-04-16T12:31:40Z")

</div>

Hello Colin,

this template i have used is from the original instance service located in /lib/systemd/system/nodered.service

```auto
[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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 April 2025 12:32 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/9 "2025-04-16T12:32:52Z")

</div>

> [@BambosD](#):
>
> node-red -u user1 -p 1882
> 
> 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

So add them as NODE\_RED\_OPTIONS in your service file

```bash
Environment="NODE_RED_OPTIONS=-p=1882 -u=/home/user/nodered2"

```

then stop/start the service

* * *

### NOTE

`-u` is for `userDir` (where node-red flows will be saved)

> [@BambosD](#):
>
> -u user1

so that should point to an absolute path as I did in the above NODE\_RED\_OPTIONS example

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 April 2025 13:01 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/10 "2025-04-16T13:01:43Z")

</div>

Did you run daemon-reload?

@Steve-Mcl I can't see why what has been done does not work.

---

<div class="post-metadata">

**Author:** ![BambosD](https://avatars.discourse-cdn.com/v4/letter/b/54ee81/32.png) [@BambosD](https://discourse.nodered.org/u/BambosD)\
**Post date:** [16 April 2025 13:23 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/11 "2025-04-16T13:23:24Z")

</div>

i confirm that options in the service file works.

while the service is starting, is not respecting the settings.js port setting. is trying to load on the default 1880.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 April 2025 13:25 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/12 "2025-04-16T13:25:16Z")

</div>

> [@BambosD](#):
>
> i confirm that options in the service file works.

Is it using the correct settings file now?

---

<div class="post-metadata">

**Author:** ![BambosD](https://avatars.discourse-cdn.com/v4/letter/b/54ee81/32.png) [@BambosD](https://discourse.nodered.org/u/BambosD)\
**Post date:** [16 April 2025 13:30 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/13 "2025-04-16T13:30:14Z")

</div>

the options in the service is overriding the settings.js file.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [16 April 2025 13:45 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/14 "2025-04-16T13:45:38Z")

</div>

So it is still picking up the wrong settings file.  
If you add `-s /full/path/to/settings.js` that should fix that.

---

<div class="post-metadata">

**Author:** ![jeenny71](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jeenny71/32/100213_2.png) [@jeenny71](https://discourse.nodered.org/u/jeenny71)\
**Post date:** [17 April 2025 05:47 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/15 "2025-04-17T05:47:48Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![gemini86](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gemini86/32/70967_2.png) [@gemini86](https://discourse.nodered.org/u/gemini86)\
**Post date:** [21 April 2025 13:47 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/16 "2025-04-21T13:47:18Z")

</div>

What I do for this is to create another user for each instance and create a new service file, pointing to the new user working directory. Changing the user and group within the service file automatically has it look for/create the .node-red folder with new settings file, or you can create these ahead of creating the new service file. For increased ease of use, I also create a virtual ethernet port with a new IP address and bind the new node-red instance to it so I can use port 1880 (or whatever I want) on all instances (this is optional).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 July 2025 13:47 UTC](https://discourse.nodered.org/t/run-node-red-instance-as-a-service-with-dedicated-folder/96602/17 "2025-07-20T13:47:54Z")

</div>

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