0
My environment is Ubuntu and I’m having trouble accessing files that are inside a folder that is subfolder of my project folder. Here’s the code:
const httpsOptions = {
cert: fs.readFileSync(path.join(__dirname, 'ssl', 'fullchain.pem')),
key: fs.readFileSync(path.join(__dirname, 'ssl', 'privkey.pem'))
};
server = https.createServer(httpsOptions, app).listen(PORT, () =>{
console.log("Server UP: " + ip.address() + ":" + PORT );
});
}
The error returned is:
fs.js:646
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES: permission denied, open '/home/ubuntu/vienna-server/ssl/fullchain.pem'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.readFileSync (fs.js:551:33)
at Object.<anonymous> (/home/ubuntu/vienna-server/server.js:120:12)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
I looked for similar solutions and nothing to solve my problem. I tried running the command sudo chmod -R 777 ubuntu ssl/*
and unsuccessfully.
Some help, I’d really appreciate it.
This must be happening because your user does not own the file, do the following in the folder where this file is
fullchain.pem
executels -l
see if in front of the file this something likeroot root
, if that is the case then runsudo chown <seu user> <arquivo>
this will make your user also own the file.– Chance
I usually use sudo before the command....
– Renato Souza