# EACCES: permission error when using port 80 with Docker images for node 16/18

**URL:** <https://discourse.nodered.org/t/eacces-permission-error-when-using-port-80-with-docker-images-for-node-16-18/65138>\
**Category:** General\
**Tags:** docker\
**Created:** [15 July 2022 10:06 UTC](https://discourse.nodered.org/t/eacces-permission-error-when-using-port-80-with-docker-images-for-node-16-18/65138 "2022-07-15T10:06:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TobiasBg](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasbg/32/64663_2.png) [@TobiasBg](https://discourse.nodered.org/u/TobiasBg)\
**Post date:** [15 July 2022 10:06 UTC](https://discourse.nodered.org/t/eacces-permission-error-when-using-port-80-with-docker-images-for-node-16-18/65138/1 "2022-07-15T10:06:55Z")

</div>

Hi!

Now that 3.0 is out, I wanted to use that opportunity to also switch to the Docker images that have a more recent version of node.

I've been successfully running this docker-compose.yml file on a RPi 4B:

```auto
version: "3.8"
services:
  nodered:
    image: nodered/node-red:3.0.0-14-minimal
    privileged: true
    user: root:root
    cap_add:
      - SYS_ADMIN
      - NET_ADMIN
    volumes:
      - ./data/nodered:/data
      - /etc/localtime:/etc/localtime
    depends_on:
      - mqtt
    network_mode: host
    restart: always
    environment:
      - TZ=Europe/Berlin

```

I'm mainly running as `root` and use the `host` network mode to be able to use port 80 for Alexa emulation, via `node-red-contrib-amazon-echo`.

Now, when I try both of `nodered/node-red:3.0.0-16-minimal` and `nodered/node-red:3.0.0-18-minimal`, i.e. updated versions of node as the image, during startup, I get this error:  
`[error] Error: listen EACCES: permission denied 0.0.0.0:80`  
(via `docker compose logs -f`).

Does anybody know why this happens with the 16 and 18 Docker images, but not the 14 one?

Thanks a lot!  
Tobias

---

<div class="post-metadata">

**Author:** ![Sylvan](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@Sylvan](https://discourse.nodered.org/u/Sylvan)\
**Post date:** [18 July 2022 03:29 UTC](https://discourse.nodered.org/t/eacces-permission-error-when-using-port-80-with-docker-images-for-node-16-18/65138/2 "2022-07-18T03:29:58Z")

</div>

Just to push the thread a bit again:  
I faced exactly the same problem after the update to 3.0.

But just the info that it works with node 14 helped me in the short term.  
However, I have not yet come closer to a fundamental solution of the phenomenon.

---

<div class="post-metadata">

**Author:** ![TobiasBg](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasbg/32/64663_2.png) [@TobiasBg](https://discourse.nodered.org/u/TobiasBg)\
**Post date:** [20 July 2022 08:01 UTC](https://discourse.nodered.org/t/eacces-permission-error-when-using-port-80-with-docker-images-for-node-16-18/65138/3 "2022-07-20T08:01:17Z")

</div>

@hardillb As the maintainer of the Docker images, do you maybe have any ideas or suggestions here? Is it maybe something about the node base image?

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [20 July 2022 08:33 UTC](https://discourse.nodered.org/t/eacces-permission-error-when-using-port-80-with-docker-images-for-node-16-18/65138/4 "2022-07-20T08:33:02Z")

</div>

The problem is that Node have changed how npm works when run as root, it now automatically remaps it's self to run as the user that owns the directory where the package.json file lives (in this case the node-red user). I really don't like this change and I'm looking at what to do to fix it, but it will not be a quick change.

The npm version packaged with the nodejs 14 build will be older than the change.

> <https://github.com/node-red/node-red-docker/issues/321>
>
> NPM seems to have changed the way it runs scripts, see \<https://github.com/npm/c…li/issues/4811\>, which causes node-red to not be executed with the user that you expect.
> 
> \### What are the steps to reproduce?
> \`\`\`bash
> root@debian:~# rm -rf nrdata/; docker run -it --rm -u root -p 1880:1880 -v $(pwd)/nrdata:/data --name nodered nodered/node-red:3.0.0
> \`\`\`
> 
> \### What happens?
> \`\`\`
> \> node-red-docker@3.0.0 start
> \> node $NODE\_OPTIONS node\_modules/node-red/red.js $FLOWS "--userDir" "/data"
> 
> node:internal/fs/utils:345
> throw err;
> ^
> 
> Error: EACCES: permission denied, copyfile '/usr/src/node-red/node\_modules/node-red/settings.js' -\> '/data/settings.js'
> at Object.copyFileSync (node:fs:2817:3)
> at copyFile (/usr/src/node-red/node\_modules/fs-extra/lib/copy/copy-sync.js:73:6)
> at onFile (/usr/src/node-red/node\_modules/fs-extra/lib/copy/copy-sync.js:59:25)
> at getStats (/usr/src/node-red/node\_modules/fs-extra/lib/copy/copy-sync.js:51:44)
> at handleFilterAndCopy (/usr/src/node-red/node\_modules/fs-extra/lib/copy/copy-sync.js:36:10)
> at Object.copySync (/usr/src/node-red/node\_modules/fs-extra/lib/copy/copy-sync.js:29:10)
> at Object.\<anonymous\> (/usr/src/node-red/node\_modules/node-red/red.js:129:20)
> at Module.\_compile (node:internal/modules/cjs/loader:1105:14)
> at Object.Module.\_extensions..js (node:internal/modules/cjs/loader:1159:10)
> at Module.load (node:internal/modules/cjs/loader:981:32) {
> errno: -13,
> syscall: 'copyfile',
> code: 'EACCES',
> path: '/usr/src/node-red/node\_modules/node-red/settings.js',
> dest: '/data/settings.js'
> }
> \`\`\`
> You can verify this is due to npm by running the script directly through node
> \`\`\`
> root@debian:~# rm -rf nrdata/; docker run -it --rm -u root --entrypoint /bin/bash -p 1880:1880 -v $(pwd)/nrdata:/data --name nodered nodered/node-red:3.0.0
> bash-5.1# node node\_modules/node-red/red.js
> \`\`\`
> which works as expected.
> 
> \### What do you expect to happen?
> I expect this to work as before with \*\*2.x\*\*.
> \`\`\`bash
> root@debian:~# rm -rf nrdata/; docker run -it --rm -u root -p 1880:1880 -v $(pwd)/nrdata:/data --name nodered nodered/node-red:2.2.2
> \`\`\`
> \`\`\`
> \> node-red-docker@2.2.2 start /usr/src/node-red
> \> node $NODE\_OPTIONS node\_modules/node-red/red.js $FLOWS "--userDir" "/data"
> 
> 18 Jul 22:09:40 - \[info\]
> 
> Welcome to Node-RED
> ===================
> ...
> \`\`\`
> 
> \### Please tell us about your environment:
> 
> Platform/OS: Debian 11 64bit

But unless you have a **VERY VERY** good reason you should **NOT** be running node-red as root you really shouldn't be and just to run on port 80 directly isn't a good reason. Either use Dockers port mapping to map the exposed port to port 1880 or run a real HTTP server as a reverse proxy infront of Node-RED.

---

<div class="post-metadata">

**Author:** ![TobiasBg](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tobiasbg/32/64663_2.png) [@TobiasBg](https://discourse.nodered.org/u/TobiasBg)\
**Post date:** [20 July 2022 12:25 UTC](https://discourse.nodered.org/t/eacces-permission-error-when-using-port-80-with-docker-images-for-node-16-18/65138/5 "2022-07-20T12:25:55Z")

</div>

Hi @hardillb,

thanks a lot! Yes, this would explain this problem! It would be great if you could find a solution for this in the Node-RED Docker images for this!

And I totally agree that running as the root user should be avoided, but I haven't yet found a way for my specific setup. I'm using `node-red-contrib-amazon-echo` (the local Alexa hub emulation, in contrast to the cloud/skill-based variant that your service offers), and due to the Alexa-port-80-requirement and the need for SSDP, I believe that Docker's `network: host` mode is [needed](https://github.com/datech/node-red-contrib-amazon-echo/wiki/Troubleshooting#node-red-in-a-docker-container) (and port mapping are not taken into account then). And this again means that I need `root` to be able to use port 80...

Best wishes,  
Tobias

---

<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:** [18 September 2022 12:26 UTC](https://discourse.nodered.org/t/eacces-permission-error-when-using-port-80-with-docker-images-for-node-16-18/65138/6 "2022-09-18T12:26:57Z")

</div>

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