# Settings.js "Error writing settings.js:Permission denied"

**URL:** <https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035>\
**Category:** General\
**Created:** [3 August 2018 22:39 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035 "2018-08-03T22:39:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweetwater](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sweetwater](https://discourse.nodered.org/u/sweetwater)\
**Post date:** [3 August 2018 22:39 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/1 "2018-08-03T22:39:34Z")

</div>

Trying to set the a Username and Password for Node Red.

The instructions require that in "settings.js" be modfied.

I have edited the field and removed the comment //.  
Then tried to save by pressing ctrl+o ( ^o)  
However i get Error " Error writing settings.js: Permission denied"

Any suggestions?

adminAuth:{  
type: "credentials",  
.....  
.....  
},

---

<div class="post-metadata">

**Author:** ![sweetwater](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sweetwater](https://discourse.nodered.org/u/sweetwater)\
**Post date:** [3 August 2018 22:57 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/2 "2018-08-03T22:57:11Z")

</div>

figured it out. need to enter sudo nano settings.js ( forgot to type in the sudo)

---

<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:** [4 August 2018 06:26 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/3 "2018-08-04T06:26:42Z")

</div>

Which settings.is are you editing? If you look at the node red log it will tell you which one it is using. Normally this will be .node-red/settings.js and should not need sudo to edit.

---

<div class="post-metadata">

**Author:** ![sweetwater](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sweetwater](https://discourse.nodered.org/u/sweetwater)\
**Post date:** [4 August 2018 15:32 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/4 "2018-08-04T15:32:02Z")

</div>

Thank you Collin.  
During bootup, the PI shows that following path name:  
"usr/lib/node\_modules/node-red/settings.js"

the Node Red was installed from the NOOB installation

1. I am pretty confused on where the settings.js file should be.  
Is the settings.js supposed to be located elsewhere?

---

<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:** [4 August 2018 15:48 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/5 "2018-08-04T15:48:57Z")

</div>

You should run the bash \<(curl upgrade script from the pi installation docs [1]. Then your flows file and settings.js should be in ~/.node-red. The pre-installed node-red is out of date.

[1] [https://nodered.org/docs/hardware/raspberrypi](https://nodered.org/docs/hardware/raspberrypi)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [4 August 2018 16:33 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/6 "2018-08-04T16:33:33Z")

</div>

Normally on first run the settings.js file gets copied to ~/.node-red/ directory and is used from there. There are a few reasons why this may not happen (which I can’t recall). You could move it manually I think.

---

<div class="post-metadata">

**Author:** ![sweetwater](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sweetwater](https://discourse.nodered.org/u/sweetwater)\
**Post date:** [6 August 2018 18:41 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/7 "2018-08-06T18:41:03Z")

</div>

Thank you Colin.  
Ran the bash \< curl( ) as you suggested. The directories are all in the /pi/home now.  
THank you

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [5 September 2019 13:57 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/8 "2019-09-05T13:57:56Z")

</div>

Hi all...  
Want to setup some user/pass and always get settings.js as read only.  
My settings.js seems to be the one at: /snap/node-red/388/lib/node\_modules/node-red, there are others but this in the only one that shown contents that include the adminAuth: {... and all the rest.  
It is always read only owned by root.  
Sudo cannot changed it. sudo -i turns me into root but I still find the file read only.  
Tried changing current dir to the path above and execute: sudo chmod 766 -R settings.js  
But still cannot edit settings.js, read only

What am I doing wrong?  
Regards  
Paulo

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [5 September 2019 14:00 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/9 "2019-09-05T14:00:50Z")

</div>

Hi Paulo, how do you run node-red normally? From a service, calling `sudo node-red` or something else entirely?

---

<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:** [5 September 2019 14:04 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/10 "2019-09-05T14:04:26Z")

</div>

> [@pcborges](#):
>
> My settings.js seems to be the one at: /snap/node-red/388/lib/node\_modules/node-red

That should indeed be read-only and should not be the live version you are running with. That one would appear to be the master one provided in the Node-RED package.

You should have another one in your userDir folder so that is what you need to focus on. If you don't have it there, you can manually copy it from the other location.

That you cannot edit it is a benefit and one I suspect that snap is enforcing somehow.

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [5 September 2019 14:21 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/11 "2019-09-05T14:21:52Z")

</div>

Hi, I see...  
Excuse my ignorance but when I open terminal and type ls what I see is:  
pcborges@ubuntu:~$ ls  
'Area de Trabalho' Downloads influxdbinstall Music snap  
Documents Images Models Public Videos

I see no node-red  
Should I create a node-red folder?  
Where do I copy settings.js to?  
Thanks  
Paulo

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [5 September 2019 14:24 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/12 "2019-09-05T14:24:16Z")

</div>

Hi afelix,  
I do nothing, installed, reboot and it is running.  
Thanks  
Paulo

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [5 September 2019 14:28 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/13 "2019-09-05T14:28:46Z")

</div>

> [@pcborges](#):
>
> pcborges@ubuntu:~$ ls

The node-red folder starts with a `.`, that means it's hidden from the view by default. If you pass the `-a` option it will show everything including hidden files/folders. If you add `-l` it will show it as list:  
`ls -a -l`

```auto
afelix@Hewlett:~$ ls -a -l
total 1464
drwxr-xr-x+ 108 afelix staff 3456 Sep 1 11:55 .
drwxr-xr-x 6 root admin 192 Mar 28 16:06 ..
-rw-r--r--@ 1 afelix staff 69636 Sep 4 08:23 .DS_Store
drwx------ 2 afelix staff 64 Aug 28 16:31 .Trash
-rw------- 1 afelix staff 0 Sep 26 2016 .Xauthority
drwxr-xr-x 6 afelix staff 192 Dec 29 2018 .heroku
-rw------- 1 afelix staff 213 Dec 28 2018 .netrc
drwxr-xr-x 4 afelix staff 128 May 18 2017 .node-gyp
drwxr-xr-x 16 afelix staff 512 Aug 23 14:28 .node-red
drwxr-xr-x 2440 afelix staff 78080 Aug 21 20:40 .npm

```

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [5 September 2019 14:32 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/14 "2019-09-05T14:32:38Z")

</div>

Great, it is indeed there. Thanks  
cd .node-red worked but the directory is empty  
So, I assume I copy settings.js to /snap/node-red/388/lib/node\_modules/node-red and edit it accordingly right?  
Thanks again

---

<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:** [5 September 2019 14:35 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/15 "2019-09-05T14:35:04Z")

</div>

Clearly, your installation went wrong because Node-RED would populate the .node-red folder upon first run. It will copy over settings.js, create your initial flows files and a package.json.

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [5 September 2019 14:44 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/16 "2019-09-05T14:44:31Z")

</div>

Something is still wrong...  
I copied the settings.js from the folder /snap/node-red/388/lib/node\_modules/node-red into the folder .node-red (under home) and uncommented:

```auto
adminAuth: {
    type: "credentials",
    users: [ {
            username: "admin",
            password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.",
            permissions: "*"
        } ]
}

```

Reboot  
Browsed from another computer into: [http://192.168.99.105:1880/](http://192.168.99.105:1880/)  
But node-red asks for no password, goes straight into the editor.

Should I uninstall and reinstall node-red?  
I did an automatic install using ubuntu GUI, is it ok?

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [5 September 2019 14:46 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/17 "2019-09-05T14:46:29Z")

</div>

Back to my earlier question, how do you start node-red?

> [@Settings.js "Error writing settings.js:Permission denied"](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/9):
>
> Hi Paulo, how do you run node-red normally? From a service, calling sudo node-red or something else entirely?

When it starts it shows you a log of what settings file it is using, node-red version, node version and so on. Are you sure the settings.js file in `~/.node-red` is being used?

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [5 September 2019 14:49 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/18 "2019-09-05T14:49:02Z")

</div>

As I said, I just installed using Ubuntu GUI and that is all I did  
When I reboot the HiperV machine node-red is already running.

pcborges@ubuntu:~/.node-red$ ls  
settings.js

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [5 September 2019 14:51 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/19 "2019-09-05T14:51:29Z")

</div>

I'm not sure if you said "Ubuntu GUI" specifically but I'm going to assume you said so and just move on. Does Ubuntu use SystemD these days or something else? Can you try the following two commands and post the output, I don't know which of those you need:  
`sudo systemctl status node-red`  
`sudo service node-red status`

---

<div class="post-metadata">

**Author:** ![pcborges](https://avatars.discourse-cdn.com/v4/letter/p/8edcca/32.png) [@pcborges](https://discourse.nodered.org/u/pcborges)\
**Post date:** [5 September 2019 14:58 UTC](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035/20 "2019-09-05T14:58:50Z")

</div>

GUI, I am referring to the the graphic user interface, not the command prompt.

The first returns:  
sudo: system: command not found

The second returns:  
Unit node-red.service could not be found

I am transcribing because the browser is not in the virtual machine running ubuntu...

Looks like something definitely went wrong during the install but except for this authentication problem node red is working and integrating with grafana without any other problem.

* * *

Hi, cannot post more than 3 repplies...

I assume deinstall using the Ubuntu user interface.  
Will do and report back  
Thanks

###############################################################  
Hi there...  
Still cannot post new replies...  
But just did uninstall using the GUI and reinstalled according to the link  
Works perfect, even took the settings.js I have created with the password I defined.  
Thanks a lot!  
Paulo

[Next page](https://discourse.nodered.org/t/settings-js-error-writing-settings-js-permission-denied/2035.md?page=2)
