# Node Red Password

**URL:** <https://discourse.nodered.org/t/node-red-password/33040>\
**Category:** General\
**Created:** [18 September 2020 12:20 UTC](https://discourse.nodered.org/t/node-red-password/33040 "2020-09-18T12:20:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mario](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Mario](https://discourse.nodered.org/u/Mario)\
**Post date:** [18 September 2020 12:20 UTC](https://discourse.nodered.org/t/node-red-password/33040/1 "2020-09-18T12:20:35Z")

</div>

**Hello,**  
**after several attempts it is not possible for me to protect my node red with a password. I'll send you the content of the config:**

```
   adminAuth: {
          type: "credentials",
          users: [{
          username: "admin",
          password: "my generated Hash",
          permissions: "*"
                 }]
    },

```

**I get the following error message:**

Error loading settings file: /home/pi/.node-red/settings.js  
/home/pi/.node-red/settings.js:21  
users: [{  
^  
SyntaxError: Unexpected token :  
at Module.\_compile (internal/modules/cjs/loader.js:723:23)  
at Object.Module.\_extensions..js (internal/modules/cjs/loader.js:789:10)  
at Module.load (internal/modules/cjs/loader.js:653:32)  
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)  
at Function.Module.\_load (internal/modules/cjs/loader.js:585:3)  
at Module.require (internal/modules/cjs/loader.js:692:17)  
at require (internal/modules/cjs/helpers.js:25:18)  
at Object. (/usr/lib/node\_modules/node-red/red.js:119:20)  
at Module.\_compile (internal/modules/cjs/loader.js:778:30)  
at Object.Module.\_extensions..js (internal/modules/cjs/loader.js:789:10)  
nodered.service: Succeeded.

**I stick to the exact descriptions on the net. But can't find my fault.**

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [18 September 2020 12:26 UTC](https://discourse.nodered.org/t/node-red-password/33040/2 "2020-09-18T12:26:56Z")

</div>

Difficult to say without the surrounding context in the settings file. Maybe a comma is missing after the last setting before adminAuth?

I've had something like this happen couple of times. Once I couldn't spot the error no matter how long I looked. I then rewrote the new part again and the issue disappeared. It might have been an invisible character somehow gotten there.

---

<div class="post-metadata">

**Author:** ![Mario](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Mario](https://discourse.nodered.org/u/Mario)\
**Post date:** [18 September 2020 12:51 UTC](https://discourse.nodered.org/t/node-red-password/33040/3 "2020-09-18T12:51:01Z")

</div>

There are no further entries in the config. This is now the 3rd attempt on 2 different raspis.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [18 September 2020 12:54 UTC](https://discourse.nodered.org/t/node-red-password/33040/4 "2020-09-18T12:54:13Z")

</div>

Have you put the `adminAuth` block you are adding _inside_ the `module.exports` block that starts on line 21 of the default settings file?

The fact it is complaining about line 21 suggests to me you have added this _outside_ of the `module.exports` block.

---

<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:** [18 September 2020 12:59 UTC](https://discourse.nodered.org/t/node-red-password/33040/5 "2020-09-18T12:59:05Z")

</div>

If you still can't get to the solution then post the whole settings file here. Use the `</>` button at the top of the edit window to paste it here.  
Also are you sure you are editing the right file? The node-red startup log tells you where it is.

---

<div class="post-metadata">

**Author:** ![Mario](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Mario](https://discourse.nodered.org/u/Mario)\
**Post date:** [18 September 2020 13:03 UTC](https://discourse.nodered.org/t/node-red-password/33040/6 "2020-09-18T13:03:55Z")

</div>

```auto
        adminAuth: {
              type: "credentials",
              users: [{
              username: "admin",
              password: "my Hash",
              permissions: "*"
                     }]
        },

```

That's all that is in the settings

Here is the path:

sudo nano /home/pi/.node-red/settings.js

---

<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:** [18 September 2020 13:07 UTC](https://discourse.nodered.org/t/node-red-password/33040/7 "2020-09-18T13:07:11Z")

</div>

> [@Mario](#):
>
> That's all that is in the settings

What happened to the original contents?

---

<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:** [18 September 2020 13:08 UTC](https://discourse.nodered.org/t/node-red-password/33040/8 "2020-09-18T13:08:02Z")

</div>

Hold on, that doesn't make sense, it is complaining about line 21 but there are not 21 lines in that file.

Edit: Did you run node-red before editing the settings file? If not then move it away and move away the flows file (if there is one) and run node red, I think that will create the basic settings file.

Also, how did you install node-red?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [18 September 2020 13:25 UTC](https://discourse.nodered.org/t/node-red-password/33040/9 "2020-09-18T13:25:43Z")

</div>

> [@Mario](#):
>
> That's all that is in the settings

Okay - so that's the issue then.

When Node-RED first runs, it copies into `~/.node-red/settings.js` the default settings file for you to edit.

Delete the file you've created, run Node-RED so it can create the file, then stop Node-RED and edit the file it has created.

---

<div class="post-metadata">

**Author:** ![Mario](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@Mario](https://discourse.nodered.org/u/Mario)\
**Post date:** [18 September 2020 13:43 UTC](https://discourse.nodered.org/t/node-red-password/33040/10 "2020-09-18T13:43:22Z")

</div>

That was exactly it.

I always changed the config first instead of starting node red once.

So many hours wasted and the answer was so close.

Many, many thanks for your help!

---

<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:** [2 October 2020 13:43 UTC](https://discourse.nodered.org/t/node-red-password/33040/11 "2020-10-02T13:43:26Z")

</div>

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