# Error: ENOENT: no such file or directory, open 'privkey.pem'

**URL:** https://discourse.nodered.org/t/error-enoent-no-such-file-or-directory-open-privkey-pem/47651
**Category:** General
**Created:** [25 June 2021 11:23 UTC](https://discourse.nodered.org/t/error-enoent-no-such-file-or-directory-open-privkey-pem/47651 "2021-06-25T11:23:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![richardche](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@richardche](https://discourse.nodered.org/u/richardche)
#### Post date: [25 June 2021 11:23 UTC](https://discourse.nodered.org/t/error-enoent-no-such-file-or-directory-open-privkey-pem/47651/1 "2021-06-25T11:23:16Z")

</div>

I installed the Node-Red docker (version 1.3.5) into QNAP NAS container station successfully, but have not managed to make the https function work yet. I mapped the "/data" folder of the docker to "/share/Storage/NASSoftwares/node-red", so that I can edit "settings.js".

In "settings.js", I uncommented the following lines:

```auto
adminAuth: {
    type: "credentials",
    users: [{
        username: "NOTREAL",
        password: "$NOTREALNOTREALNOTREALNOTREALNOTREALNOTREAL",
        permissions: "*"
    }]
},

https: function() {
     // This function should return the options object, or a Promise
     // that resolves to the options object
     return {
         key: require("fs").readFileSync('privkey.pem'),
         cert: require("fs").readFileSync('fullchain.pem')
     }
 },

```

Then when I tried to start the docker, the docker gave me the following info:

```auto
Error: ENOENT: no such file or directory, open 'privkey.pem'                                                                                                                                                                      
    at Object.openSync (fs.js:443:3)                                                                                                                                                                                              
    at Object.readFileSync (fs.js:343:35)                                                                                                                                                                                         
    at https (/data/settings.js:160:29)                                                                                                                                                                                           
    at Object.<anonymous> (/usr/src/node-red/node_modules/node-red/red.js:203:20)                                                                                                                                                 
    at Module._compile (internal/modules/cjs/loader.js:778:30)                                                                                                                                                                    
    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 Function.Module.runMain (internal/modules/cjs/loader.js:831:12)                                                                                                                                                            
npm ERR! code ELIFECYCLE                                                                                                                                                                                                          
npm ERR! errno 1                                                                                                                                                                                                                  
npm ERR! node-red-docker@1.3.5 start: `node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS "--userDir" "/data"`                                                                                                                
npm ERR! Exit status 1                                                                                                                                                                                                            
npm ERR!                                                                                                                                                                                                                          
npm ERR! Failed at the node-red-docker@1.3.5 start script.                                                                                                                                                                        
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.                                                                                                                                
                                                                                                                                                                                                                                  
npm ERR! A complete log of this run can be found in:                                                                                                                                                                              
npm ERR! /data/.npm/_logs/2021-06-25T10_57_20_767Z-debug.log

```

Only when I re-commented the cert and key out can the docker start again. I used the docker terminal to use "ls" to show all the files in the docker, only these two appeared:

```auto
node_modules package.json

```

However, when I tried to access the same folder through samba or WINSCP, I could see a whole bunch of other stuff showing up as follows:

```auto
.config.nodes.json
.config.nodes.json.backup
.config.runtime.json
.config.users.json
.config.users.json.backup
.flows.json.backup
.npm
flows.json
fullchain.pem
lib
node_modules
node-red-contrib-home-assistant-websocket.json
package.json
package-lock.json
privkey.pem
settings.js
ssh

```

I assumed that it was a permissions problem, so I used WINSCP to modify my fullchain.pem and privkey.pem to share identical group, owner and other permissions settings with package.json (i.e. the file that did show up in the response of "ls" command in the docker), but nothing changed as the docker still showed the same error message. I have struggled with this for days, and researched all the relevant posts on the Internet, so if anyone can point me to the right direction, I would appreciate it so much.

---

<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: [25 June 2021 12:17 UTC](https://discourse.nodered.org/t/error-enoent-no-such-file-or-directory-open-privkey-pem/47651/2 "2021-06-25T12:17:23Z")

</div>

Change `privkey.pem` to the full path to the file (from the point of view of the container) - so `/data/privkey.pem`.

Without the full path, node will treat it as a file relative to the working directory of the process. The Node-RED Docker image's working directory is not `/data`.

---

<div class="post-metadata">

### Author: ![richardche](https://avatars.discourse-cdn.com/v4/letter/r/6f9a4e/32.png) [@richardche](https://discourse.nodered.org/u/richardche)
#### Post date: [25 June 2021 15:55 UTC](https://discourse.nodered.org/t/error-enoent-no-such-file-or-directory-open-privkey-pem/47651/3 "2021-06-25T15:55:59Z")

</div>

Yes! Adding "/data" definitely did the trick! Thank you for your quick reply!

---

<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: [9 July 2021 15:56 UTC](https://discourse.nodered.org/t/error-enoent-no-such-file-or-directory-open-privkey-pem/47651/4 "2021-07-09T15:56:32Z")

</div>

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