# Starting node-red

**URL:** <https://discourse.nodered.org/t/starting-node-red/42693>\
**Category:** General\
**Created:** [16 March 2021 05:49 UTC](https://discourse.nodered.org/t/starting-node-red/42693 "2021-03-16T05:49:20Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eintracht00](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@Eintracht00](https://discourse.nodered.org/u/Eintracht00)\
**Post date:** [16 March 2021 05:49 UTC](https://discourse.nodered.org/t/starting-node-red/42693/1 "2021-03-16T05:49:20Z")

</div>

Hello, i normally start node-red with my computer {local}  
but today i want to start with  
"node-red".  
16 Mar 06:45:55 - [info] Node-RED version: v1.2.9  
16 Mar 06:45:55 - [info] Node.js version: v15.10.0  
16 Mar 06:45:55 - [info] Windows\_NT 10.0.19041 x64 LE  
16 Mar 06:45:56 - [info] Loading palette nodes  
16 Mar 06:45:57 - [info] Settings file : C:\Users\Nutzer.node-red\settings.js  
16 Mar 06:45:57 - [info] Context store : 'default' [module=memory]  
16 Mar 06:45:57 - [info] User directory : C:\Users\Nutzer.node-red  
16 Mar 06:45:57 - [warn] Projects disabled : editorTheme.projects.enabled=false  
16 Mar 06:45:57 - [info] Flows file : C:\Users\Nutzer.node-red\flows\_DE12785648H7.json  
16 Mar 06:45:57 - [error] Uncaught Exception:  
16 Mar 06:45:57 - [error] Error: listen EADDRINUSE: address already in use 0.0.0.0:1880  
at Server.setupListenHandle [as \_listen2] (node:net:1310:16)  
at listenInCluster (node:net:1358:12)  
at doListen (node:net:1496:7)  
at processTicksAndRejections (node:internal/process/task\_queues:82:21)

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [16 March 2021 06:03 UTC](https://discourse.nodered.org/t/starting-node-red/42693/2 "2021-03-16T06:03:22Z")

</div>

You already have your other instance running on port 1880. You can't use the same port twice.

Either stop the other one automatically starting with your computer, or try using `-p` to specify another port.  
You also have to take care of the workspace, usually `.node-red` in your user dir. Only one instance can use it at a time.  
So you'd have to pass an alternative directory using the `-u` parameter as well.

Like  
`node-red -p 1881 -u [path/to/workspace]`

---

<div class="post-metadata">

**Author:** ![Eintracht00](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@Eintracht00](https://discourse.nodered.org/u/Eintracht00)\
**Post date:** [16 March 2021 06:08 UTC](https://discourse.nodered.org/t/starting-node-red/42693/3 "2021-03-16T06:08:10Z")

</div>

But last 2 month i just started like this and everything works. how can i stop the other than? I only use node-red on this port..

---

<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 March 2021 07:47 UTC](https://discourse.nodered.org/t/starting-node-red/42693/4 "2021-03-16T07:47:57Z")

</div>

This looks very similar to this \>\> [Start up error - Uncaught Exception - #6 by Steve-Mcl](https://discourse.nodered.org/t/start-up-error-uncaught-exception/42588/6)

Try the advice in that thread.

---

<div class="post-metadata">

**Author:** ![Eintracht00](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@Eintracht00](https://discourse.nodered.org/u/Eintracht00)\
**Post date:** [16 March 2021 08:12 UTC](https://discourse.nodered.org/t/starting-node-red/42693/5 "2021-03-16T08:12:50Z")

</div>

I just closed all windows and startet my PC new -\> than it works normally

---

<div class="post-metadata">

**Author:** ![Lupin\_III](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lupin_iii/32/67650_2.png) [@Lupin\_III](https://discourse.nodered.org/u/Lupin_III)\
**Post date:** [26 March 2021 01:34 UTC](https://discourse.nodered.org/t/starting-node-red/42693/6 "2021-03-26T01:34:15Z")

</div>

Hi, always with regard of starting node-red, I've noticed two different behavior on windows and raspberry, running node-red from command line in this way:

- windows: node-red -u C:\Users\me\.node-red\test1 -p 1801 flow\_test.json
- raspberry: node-red -u home/pi/.node-red/test1 -p 1801 flow\_test.json

Inside the test1 folder there is no settings.js, but:  
on windows it's used the settings.js file in .node-red folder  
on raspberry a new default settings.js file is created inside the test1 folder

Specs:  
Windows 10, node-red v1.2.9, node v14.15.4  
Raspberry pi3 B+, debian buster, node-red v1.2.9, node v12.21.0

---

<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:** [26 March 2021 07:23 UTC](https://discourse.nodered.org/t/starting-node-red/42693/7 "2021-03-26T07:23:32Z")

</div>

> [@Lupin\_III](#):
>
> windows: node-red -u C:\Users\me.node-red\test1 -p 1801 flow\_test.json

Is it the same if you launch with forward slashes?

```bash
node-red -u C:/Users/me/.node-red/test1 -p 1801 flow_test.json

```

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [26 March 2021 07:58 UTC](https://discourse.nodered.org/t/starting-node-red/42693/8 "2021-03-26T07:58:29Z")

</div>

It's definitely the backslash issue on Windows. Just tripped over it again by accident yesterday.

Always use forward slashes `/` or double backslashes `\\`. Don't press `TAB` by accident like I did, it will replace all slashes with backslashes again. 🙈

---

<div class="post-metadata">

**Author:** ![Lupin\_III](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lupin_iii/32/67650_2.png) [@Lupin\_III](https://discourse.nodered.org/u/Lupin_III)\
**Post date:** [26 March 2021 12:08 UTC](https://discourse.nodered.org/t/starting-node-red/42693/9 "2021-03-26T12:08:50Z")

</div>

Yes, it's the same. On windows it always use the settings.js file inside .node-red with all the commands (if it doesn't find the file in test1, of course):  
node-red -u C:\Users\me\.node-red\test1 -p 1801 flow\_test.json  
node-red -u C:\\Users\\me\\.node-red\\test1 -p 1801 flow\_test.json  
node-red -u C:/Users/me/.node-red/test1 -p 1801 flow\_test.json

I'm understanding that for you this is not what expected. Actually, this is what I would like to have on raspbian, too 😬 😬 😬

---

<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:** [26 March 2021 12:16 UTC](https://discourse.nodered.org/t/starting-node-red/42693/10 "2021-03-26T12:16:37Z")

</div>

Could you also try...

`node-red -u C:\Users\me\.node-red\test1\ -p 1801 flow_test.json`  
`node-red -u "C:\Users\me\.node-red\test1" -p 1801 flow_test.json`  
`node-red -u "C:\Users\me\.node-red\test1\" -p 1801 flow_test.json`

`node-red -u C:\\Users\\me\\.node-red\\test1\\ -p 1801 flow_test.json`  
`node-red -u "C:\\Users\\me\\.node-red\\test1" -p 1801 flow_test.json`  
`node-red -u "C:\\Users\\me\\.node-red\\test1\\" -p 1801 flow_test.json`

`node-red -u C:/Users/me/.node-red/test1/ -p 1801 flow_test.json`  
`node-red -u "C:/Users/me/.node-red/test1" -p 1801 flow_test.json`  
`node-red -u "C:/Users/me/.node-red/test1/" -p 1801 flow_test.json`

---

<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:** [26 March 2021 12:29 UTC](https://discourse.nodered.org/t/starting-node-red/42693/11 "2021-03-26T12:29:46Z")

</div>

The logic for finding the settings file to use is quite complex, if a the user dir is specified but the settings file does not exist there then it uses various environment vars to find it. I don't know what the logic behind that is. I guess that the two machines differ in the env settings.

```auto
if (parsedArgs.settings) {
    // User-specified settings file
    settingsFile = parsedArgs.settings;
} else if (parsedArgs.userDir && fs.existsSync(path.join(parsedArgs.userDir,"settings.js"))) {
    // User-specified userDir that contains a settings.js
    settingsFile = path.join(parsedArgs.userDir,"settings.js");
} else {
    if (fs.existsSync(path.join(process.env.NODE_RED_HOME,".config.json"))) {
        // NODE_RED_HOME contains user data - use its settings.js
        settingsFile = path.join(process.env.NODE_RED_HOME,"settings.js");
    } else if (process.env.HOMEPATH && fs.existsSync(path.join(process.env.HOMEPATH,".node-red",".config.json"))) {
        // Consider compatibility for older versions
        settingsFile = path.join(process.env.HOMEPATH,".node-red","settings.js");
    } else {
        var userDir = parsedArgs.userDir || path.join(process.env.HOME || process.env.USERPROFILE || process.env.HOMEPATH,".node-red");
        var userSettingsFile = path.join(userDir,"settings.js");
        if (fs.existsSync(userSettingsFile)) {
            // $HOME/.node-red/settings.js exists
            settingsFile = userSettingsFile;
        } else {
            var defaultSettings = path.join(__dirname,"settings.js");
            var settingsStat = fs.statSync(defaultSettings);
            if (settingsStat.mtime.getTime() <= settingsStat.ctime.getTime()) {
                // Default settings file has not been modified - safe to copy
                fs.copySync(defaultSettings,userSettingsFile);
                settingsFile = userSettingsFile;
            } else {
                // Use default settings.js as it has been modified
                settingsFile = defaultSettings;
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Lupin\_III](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lupin_iii/32/67650_2.png) [@Lupin\_III](https://discourse.nodered.org/u/Lupin_III)\
**Post date:** [30 March 2021 00:50 UTC](https://discourse.nodered.org/t/starting-node-red/42693/12 "2021-03-30T00:50:03Z")

</div>

All the instruction, apart for the 3rd one, work as the same, using the settings.js file inside ".node-red" directory if it doesn't exist in "test1"

For the 3rd instruction  
node-red -u "C:\Users\me.node-red\test1" -p 1801 flow\_test.json  
this is the result  
30 Mar 02:43:52 - [error] Failed to start server:  
30 Mar 02:43:52 - [error] Error: C:\Users\me.node-red\test1" -p 1801 flow\_test.json\node\_modules contains invalid WIN32 path characters.  
at Object.mkdirs (C:\Users\me\AppData\Roaming\npm\node\_modules\node-red\node\_modules\fs-extra\lib\mkdirs\mkdirs.js:18:22)  
at C:\Users\me\AppData\Roaming\npm\node\_modules\node-red\node\_modules\universalify\index.js:13:12  
at new Promise ()  
at Object.mkdirs (C:\Users\me\AppData\Roaming\npm\node\_modules\node-red\node\_modules\universalify\index.js:7:14)  
at Object.init (C:\Users\me\AppData\Roaming\npm\node\_modules\node-red\node\_modules@node-red\runtime\lib\storage\localfilesystem\index.js:50:22)  
at Object.init (C:\Users\me\AppData\Roaming\npm\node\_modules\node-red\node\_modules@node-red\runtime\lib\storage\index.js:74:34)  
at C:\Users\me\AppData\Roaming\npm\node\_modules\node-red\node\_modules@node-red\runtime\lib\index.js:118:43  
at tryCatchReject (C:\Users\me\AppData\Roaming\npm\node\_modules\node-red\node\_modules\when\lib\makePromise.js:845:30)  
at runContinuation1 (C:\Users\me\AppData\Roaming\npm\node\_modules\node-red\node\_modules\when\lib\makePromise.js:804:4)  
at Fulfilled.when (C:\Users\me\AppData\Roaming\npm\node\_modules\node-red\node\_modules\when\lib\makePromise.js:592:4)

---

<div class="post-metadata">

**Author:** ![Lupin\_III](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lupin_iii/32/67650_2.png) [@Lupin\_III](https://discourse.nodered.org/u/Lupin_III)\
**Post date:** [30 March 2021 01:11 UTC](https://discourse.nodered.org/t/starting-node-red/42693/13 "2021-03-30T01:11:11Z")

</div>

Thanks a lot for the explanation Colin. I'll go through specifying the settings.js file within the launching command.

Always regarding this topic, I'm trying to start a different instance of node-red at boot on a raspberry 3B + with debian stretch, but without success.  
I have disabled the default one with "sudo systemctl disable nodered.service", and following is the service file I have created, put in /etc/systemd/system, end enabled. The user is not the default "pi" but "me", user with the same privileges and groups of "pi" and where I have installed node-red (I don't remember if I did it with sudo or nor)

```auto
[Unit]
Description=personal Node-RED istance
Wants=network.target

[Service]
Type=simple
User=me
Group=me
WorkingDirectory=/home/me

Nice=5
Environment="NODE_OPTIONS=--max_old_space_size=256"
Environment="PORT=1801"
Environment="NODE_RED_OPTIONS=-u /home/me/.node-red/personal -s /home/me/.node-red/settings.js flows_scada.json"

ExecStart=/usr/bin/env node-red-me $NODE_OPTIONS $NODE_RED_OPTIONS
KillSignal=SIGINT
Restart=on-failure
RestartSec=20
SyslogIdentifier=nr_personal

[Install]
WantedBy=multi-user.target

```

---

<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:** [30 March 2021 07:42 UTC](https://discourse.nodered.org/t/starting-node-red/42693/14 "2021-03-30T07:42:48Z")

</div>

You haven't said what the problem is. Watch /var/log/syslog when you try to start it and also use  
`sudo systemctl status yourservicename`  
to see what it says.

> [@Lupin\_III](#):
>
> `ExecStart=/usr/bin/env node-red-me $NODE_OPTIONS $NODE_RED_OPTIONS`

Does `node-red-me` exist? Is there a reason you are not using `node-red-pi`?

---

<div class="post-metadata">

**Author:** ![Lupin\_III](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lupin_iii/32/67650_2.png) [@Lupin\_III](https://discourse.nodered.org/u/Lupin_III)\
**Post date:** [30 March 2021 12:01 UTC](https://discourse.nodered.org/t/starting-node-red/42693/15 "2021-03-30T12:01:17Z")

</div>

Oh sorry, you're right Colin.  
The problem is that this instance of node-red doesn't start at boot. I have to run it manually every time.  
Actually, looking at the log and the status response, it failed because "node-red-rw" desn't exist as you pointed out. I thought it was created when installing node-red as "me" user instead of "pi" user. But if I run "env", I doesn't even see "node-red-pi" in the list.  
So, the problem is "ExecStart=/usr/bin/env node-red-me $NODE\_OPTIONS $NODE\_RED\_OPTIONS" related to "node-red-me" that doesn't exist.  
How can I fix it?  
.

---

<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:** [30 March 2021 14:31 UTC](https://discourse.nodered.org/t/starting-node-red/42693/16 "2021-03-30T14:31:49Z")

</div>

`node-red-pi` is what you want. It should exist if you originally installed using the recommended script for the pi from the node-red-docs. Does  
`which node-red-pi` find it?

---

<div class="post-metadata">

**Author:** ![Lupin\_III](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lupin_iii/32/67650_2.png) [@Lupin\_III](https://discourse.nodered.org/u/Lupin_III)\
**Post date:** [1 April 2021 10:05 UTC](https://discourse.nodered.org/t/starting-node-red/42693/17 "2021-04-01T10:05:14Z")

</div>

Yes Colin, thanks a lot. It works 😉

---

<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:** [15 April 2021 10:05 UTC](https://discourse.nodered.org/t/starting-node-red/42693/18 "2021-04-15T10:05:42Z")

</div>

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