N8N_SSL_KEY issue: EACCES: permission denied, open '/root/n8n/files/n8n.key

Hello
I’m trying to install n8n via docker with pointing the installer to SSL key and SSL cert in docker-compose
so here’s docker compose file content

version: '3.3'
services:
  n8n:
    image: n8nio/n8n
    container_name: n8n
    ports:
      - '5678:5678'
    volumes:
      - /root/n8n:/home/node/.n8n
      - /root/n8n/files:/files
    environment:
      - GENERIC_TIMEZONE=Africa/Cairo
      - WEBHOOK_URL=https://sub.domain.com
      - WEBHOOK_TUNNEL_URL=https://sub.domain.com
      - VUE_APP_URL_BASE_API=https://sub.domain.com
      - N8N_HOST=sub.domain.com
      - N8N_PROTOCOL=https
    restart: unless-stopped

after the deployment, i’ve got this errors in n8n docker logs

Error: EACCES: permission denied, open '/home/node/.n8n/crash.journal' "{ file: 'ErrorReporterProxy.js', function: 'report' }"

and after searching around for this issue, i’ve found that to fix it i need to change ownership of the directory i set for n8n : /root/n8n to 1000:1000
so i’ve done this command:

chown -R 1000:1000 /root/n8n

then i’ve made a restart to n8n container and here’s the logs after


and it works but not with https, it works with http only

so, next i wanted to include SSL cert and key within the docker-compose to allow https
so i’ve set copied my subdomain certificate and key: n8n.key and n8n.crt in /root/n8n/files directory
image
and used the command:

docker-compose down

to stop and delete n8n container, and here’s the docker-compose file after SSL edit:

version: '3.3'
services:
  n8n:
    image: n8nio/n8n
    container_name: n8n
    ports:
      - '5678:5678'
    volumes:
      - /root/n8n:/home/node/.n8n
      - /root/n8n/files:/files
    environment:
      - GENERIC_TIMEZONE=Africa/Cairo
      - WEBHOOK_URL=https://sub.domain.com
      - WEBHOOK_TUNNEL_URL=https://sub.domain.com
      - VUE_APP_URL_BASE_API=https://sub.domain.com
      - N8N_HOST=sub.domain.com
      - N8N_PROTOCOL=https
      - N8N_SSL_KEY=/root/n8n/files/n8n.key
      - N8N_SSL_CERT=/root/n8n/files/n8n.crt
    restart: unless-stopped

and i spin it up and here’s the n8n logs

2023-10-13T17:56:08.145Z | info     | Initializing n8n process "{ file: 'start.js', function: 'init' }"
2023-10-13T17:56:08.330Z | debug    | Lazy Loading credentials and nodes from n8n-nodes-base "{\n  credentials: 347,\n  nodes: 440,\n  file: 'DirectoryLoader.js',\n  function: 'loadAll'\n}"
2023-10-13T17:56:08.495Z | debug    | Setting soft-deletion interval (pruning) for executions every 60 min "{\n  file: 'execution.repository.js',\n  function: 'setSoftDeletionInterval'\n}"
2023-10-13T17:56:08.496Z | debug    | Setting hard-deletion interval for executions every 15 min "{\n  file: 'execution.repository.js',\n  function: 'setHardDeletionInterval'\n}"
Error: EACCES: permission denied, open '/root/n8n/files/n8n.key'
2023-10-13T17:56:08.498Z | error    | Error: Exiting due to an error. "{ file: 'ErrorReporterProxy.js', function: 'report' }"
2023-10-13T17:56:08.499Z | error    | Error: EACCES: permission denied, open '/root/n8n/files/n8n.key' "{ file: 'ErrorReporterProxy.js', function: 'report' }"

and the current permission they have is 400 and i’ve all kind of permissions
also i’ve tried to change ownership of the key to root:root and still with the same error

the wierd thing i’ve did, that i’ve changed the docker-compose SSL key path to a fake path, and spinned the container again, and guess what !! , the same error “Error: EACCES: permission denied with the fake path of the SSL”

So, what’s going on here???
what permission i should set for the SSL key also what ownership i should set it ?

i’ve root access and i’m spinning the docker-compose using root

Information on your n8n setup

  • n8n version: 1.9.3
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: CentOS-7

a follow-up to my question
and if you are asking, why I’m not using a reverse proxy like nginx and using it

my server running WHM/cPanel with apache, and i really with i could install nginx proxy manager to map everything and set SSL easily, but it won’t deploy because of ports 443 / 80 is used by apache

also, i’m using the FQDN with port to make it work

Hey @MotazHakim,

We don’t use root as the user for n8n and it is instead the node user as you found which won’t be able to access the root path.

I would recommend using the /home/node/ paths that we document in our examples to see if that helps.

1 Like

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