EACCES: permission denied, mkdir '/.cache' when upgrading to >=0.196.0

Describe the issue/error/question

I’m running n8nio/n8n:0.195.5 on my kubernetes cluster and I can’t upgrade it to any newer version. Every time I try to release any version >= 0.196.0 I get Error: EACCES: permission denied, mkdir '/.cache' How to fix it ?

What is the error message (if any)?

2023-02-09T07:14:26.908Z | error    | Error: There was an error "{ file: 'ErrorReporterProxy.js', function: 'report' }"
2023-02-09T07:14:26.909Z | error    | Error: EACCES: permission denied, mkdir '/.cache' "{ file: 'ErrorReporterProxy.js', function: 'report' }"
2023-02-09T07:14:27.002Z | warn     | Migrations finished. "{ file: 'migrationHelpers.js' }"

Information on your n8n setup

  • n8n version: any >=1.196.0
  • Database you’re using (default: SQLite): PostgresSql
  • Running n8n with the execution process [own(default), main]: own
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hey @solveretur,

Welcome to the community :cake:

It looks like an OS permission issue, What user do you have n8n running as? At some point I think we changed to a node user so if that was trying to do something in a root owned directory it would fail.

Hi ! I am just trying to run pure n8nio/n8n:0.214.0 - I haven’t changed anything in the Dockerfile so the user is exactly the same as you defined in your image and it’s not working ;c

Hey @solveretur,

I am fairly sure we changed the user in the dockerfile, Can you share the config you are using? Maybe we can help work out what you need to change.

@solveretur do you the env variable N8N_USER_FOLDER set to / and have a volume mounted at /.n8n ?

do you the env variable N8N_USER_FOLDER set to / and have a volume mounted at /.n8n ?

Yes I did both: set N8N_USER_FOLDER and mounted a volume

      - mountPath: /.n8n
        name: n8n-home
  - name: n8n-home
    emptyDir: {}

Maybe we can help work out what you need to change.

I think it might be caused because I use

      - /usr/local/lib/node_modules/n8n/bin/n8n    
      runAsUser: 110002

What should be the correct value ?

since the last few release, n8n has stopped keeping compiled static assets in memory (to reduce the memory footprint of the service), and needs a folder to write these static assets to.
In the code this folder is defined as the ${N8N_USER_FOLDER}/.cache folder.

Usually people running n8n run it with the node user that’s defined in the container image, which makes it possible to write to /home/node/.n8n as well ass /home/node/.cache.

Since you have overridden N8N_USER_FOLDER to /, You need to either

  1. create a new volume that mounts on /.cache, and make sure that the user 110002 can write to it. Or,
  2. remove N8N_USER_FOLDER env variable, run the container as the node user, and update the mountPath for the n8n-home volume to /home/node/.n8n.

What’s key is that the user n8n is running as is able to write to .cache and .n8n folders inside the path defined via N8N_USER_FOLDER.

I added

      - mountPath: /.cache
        name: n8n-cache
  - name: n8n-cache
    emptyDir: {}

and it did the job - thanks for help !


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