Write to disk in Docker N8N - forbidden by access permission

Information on your n8n setup

  • **n8n version: 1.76.2
  • **Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • **Running n8n via Docker, npm, n8n cloud, desktop app): Docker
  • **Operating system: Ubuntu 20.04

I am new to n8n and i am now struggling with the write to disk step.
I am checking now since several ours and trying different solutions from google, the n8n community and so on, but nothing is working.

My last docker-compose file for the n8n volumes is

n8n:
    image: docker.n8n.io/n8nio/n8n
#    build: .
    restart: always
    environment:
      - N8N_SECURE_COOKIE=false
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
      - DB_POSTGRESDB_USER=${POSTGRES_NON_ROOT_USER}
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_NON_ROOT_PASSWORD}
    ports:
      - 5678:5678
    links:
      - postgres
    volumes:
      - n8n_storage:/home/node/.n8n
      - /home/rauscher/n8n/files:/files
    depends_on:
      postgres:
        condition: service_healthy

This is more or less the original docker-compose file from n8n github.
I changed the volume as mentioned in several posts to /home/rauscher/n8n/files:/files where the left side is exsiting on my linux server and the right side should be generated by the docker compose up.

after a check inside my docker the directory was created successfull, but i still get the error in the workflow

I dont know what i can change the only thing i can find is that the directory files which is created inside the docker has 1002:1002 user and not node:node.
If i try to write a file into the /home/node directory of the docker container, then its working, but this folder is not able to link to the root system.

Thanks

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Hi @arauscher ,
Don’t know much about Docker, but this might help:

Docker runs n8n as user ID 1000 ( node), and your mounted volume is owned by 1002:1002.

You may try this solution here.

Otherwise try this:

  1. Change Ownership of the Host Directory - On your Ubuntu host, run:

    sudo chown -R 1002:1002 /home/rauscher/n8n/files
    sudo chmod -R 775 /home/rauscher/n8n/files
    

    to ensure your user inside the container has write access.

  2. Restart Your Docker Containers

    docker-compose down
    docker-compose up -d
    

If this helped you, please mark my reply as correct solution✅ and give it a like❤️
Have fun!:robot:

If you are running docker with the node user you should map the volumes to a directory that node user has access to.

In your case you are running the container with user node but you have mapped the volume to the home directory of user rauscher so naturally you get access permissions.

It’s not like you can’t give node permissions to write somewhere in /home/rauscher/ like it was suggested but mixing user directories is a very bad practice and leads to chaos quickly.

A good practice is to create a directory for your persistent docker volumes and organize them by container/app

For example:

  • /opt/docker/n8n/
  • /opt/docker/postgres/
  • /opt/docker/qdrant/

Just make sure to create the sub-directory with the docker container user or change it’s owner with the chown command