N8N under Docker - no write access to SMB share on Windows Server

Hello everyone!

I’m new to the forum and have just completed my first installation on Docker based on Ubuntu. Now I need to create a workflow that fetches data and stores it on a Windows Share (Windows Server 2019). The path is mounted in FSTAB and write access from the OS is possible. Unfortunately, I can’t get N8N to access it.

The error message I’m receiving is:
The file “/data/windows/Transfer/Bestell-Lagerdaten/orders.csv” is not writable.

Here’s what my docker-compose.yml looks like:

n8n-2:
image: ‘docker.n8n.io/n8nio/n8n:latest’
container_name: n8n-server-n8n-2
restart: unless-stopped
user: “1000:1000” # <— Forces n8n to use exactly the UID of your CIFS option
volumes:

  • /home/n8n-2:/home/node/.n8n
  • /mnt/windows_export_n8n2:/data/windows # ← CHANGED: Now points directly to the host path
    environment:
  • N8N_LISTEN_ADDRESS=0.0.0.0
  • N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false
  • N8N_BLOCK_ENV_ACCESS_IN_NODE=false
  • N8N_SECURE_COOKIE=false
  • WEBHOOK_URL=URL was here
  • N8N_HOST=URL was here
  • N8N_PORT=5678
  • N8N_PROTOCOL=http
  • N8N_PROXY_HOPS=1
  • DISABLE_IPV6=true
  • N8N_EMAIL_METHOD=smtp
  • N8N_SMTP_HOST=192.168.XX.9
  • N8N_SMTP_PORT=25
  • N8N_SMTP_USER=n8n@XXXXXX.com
  • N8N_SMTP_PASS=NnXXXXXX
  • N8N_SMTP_SENDER=n8n-2@XXXXX.com
  • N8N_SMTP_SSL=false
    labels:
  • “com.centurylinklabs.watchtower.enable=true”
    networks:
  • proxy-network

Here’s the FSTAB entry:

//192.168.XX.5/Daten /mnt/windows_export_n8n2 cifs username=XW,domain=XXXX.local,password=**********,uid=1000,gid=1000,forceuid,forcegid,vers=3.0,file_mode=0777,dir_mode=0777,rw,nobrl,nofail 0 0

The file share has all the share permissions and security permissions it theoretically needs.

Do you have any idea what could be causing this?

Thank you in advance!

Hi @StephanRo

In n8n 2.0, the default changed so that file operations are restricted by default. The N8N_RESTRICT_FILE_ACCESS_TO environment variable now defaults to ~/.n8n-files — you must explicitly allow the directories you want to use. Additionally, for Docker, paths in the Read/Write Files node refer to the container’s filesystem, not your host, so mounting the Windows share as a volume is correct, but we need to tell n8n to allow access to it.

You can try this:

n8n-2:
  image: 'docker.n8n.io/n8nio/n8n:latest'
  container_name: n8n-server-n8n-2
  restart: unless-stopped
  user: "1000:1000"
  volumes:
    - /home/n8n-2:/home/node/.n8n
    - /mnt/windows_export_n8n2:/files  # ← Changed to /files
  environment:
    N8N_LISTEN_ADDRESS=0.0.0.0
    N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false
    N8N_BLOCK_ENV_ACCESS_IN_NODE=false
    N8N_SECURE_COOKIE=false
    WEBHOOK_URL=URL was here
    N8N_HOST=URL was here
    N8N_PORT=5678
    N8N_PROTOCOL=http
    N8N_PROXY_HOPS=1
    DISABLE_IPV6=true
    N8N_EMAIL_METHOD=smtp
    N8N_SMTP_HOST=192.168.XX.9
    N8N_SMTP_PORT=25
    N8N_SMTP_USER=n8n@XXXXXX.com
    N8N_SMTP_PASS=NnXXXXXX
    N8N_SMTP_SENDER=n8n-2@XXXXX.com
    N8N_SMTP_SSL=false
    N8N_RESTRICT_FILE_ACCESS_TO="/files"  # ← Add this to allow access
  labels:
    "com.centurylinklabs.watchtower.enable=true"
  networks:
    proxy-network

Then use /files/your-folder/your-file.txt as your path in the Read/Write Files node.

Wow that was fast, awesome!

What’s the best way to get started, where exactly do I enter what :slight_smile: Sorry, I’m not that deep into the topic yet.

@StephanRo

You need to modify docker-compose.yml. Make it similar to what I have posted

Hi @StephanRo Welcome!
Set the allow-list to the path you already mount, and write the value without quotes. In the environment: list form Compose keeps the quote characters as part of the value, so "/data/windows" never matches your path:

    environment:
      - N8N_RESTRICT_FILE_ACCESS_TO=/data/windows

Keep the leading dash on every line in that block, and separate several folders with a semicolon if you need more than one later.
Environment changes don’t reach a container that is already running, so recreate it instead of restarting:

docker compose up -d --force-recreate n8n-2

One small thing I’d check before changing too much: test the exact path from inside the container as the same user n8n is running as.

Something like:

docker exec -it -u 1000:1000 n8n-server-n8n-2 sh
id
ls -ld /files /files/Transfer /files/Transfer/Bestell-Lagerdaten
touch /files/Transfer/Bestell-Lagerdaten/n8n-write-test.txt

If that fails, the issue is still at the Docker mount / SMB / UID level.

If that works, then the mount is probably fine and I’d focus on the n8n-side path allowlist and making sure the node is using the container path, not the host path.

Also, if any SMTP values in the compose snippet were real, I’d rotate those after posting. Easy thing to overlook when troubleshooting.

Thanks to all of you so far, I’m on vacation right now and will give it a try right after.

The write test was successful. The file is created in the path.

I’ve adjusted that. Thanks for the tip!

I’ll test it right away from n8n.

Perfect. I would use that test to split the problem in two.

If the touch command works from inside the container, the SMB mount is probably fine and the next thing to check is the n8n file access allowlist plus the path used in the Read/Write Files node. In that case the node should use the container path, like /files/…, not the Windows or host path.

If the touch command fails inside the container, then I would fix the Docker volume / SMB permissions first before changing the workflow. That keeps you from debugging n8n when the container simply cannot write to the mounted folder yet.

Thanks colleagues! It’s done, it can now be written to the file system.

This is how we have it running now:
n8n-2:
image: ‘docker.n8n.io/n8nio/n8n:latest’
container_name: n8n-server-n8n-2
restart: unless-stopped
user: “1000:1000”
volumes:

  • /home/n8n-2:/home/node/.n8n
  • /mnt/windows_export_n8n2:/data/windows
    environment:
  • N8N_LISTEN_ADDRESS=0.0.0.0
  • N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false
  • N8N_BLOCK_ENV_ACCESS_IN_NODE=false
  • N8N_SECURE_COOKIE=false
  • WEBHOOK_URL=https://n8n2..com
  • N8N_HOST=n8n2..com
  • N8N_PORT=5678
  • N8N_PROTOCOL=http
  • N8N_PROXY_HOPS=1
  • DISABLE_IPV6=true
  • N8N_EMAIL_METHOD=smtp
  • N8N_SMTP_HOST=192.1.0.9
  • N8N_SMTP_PORT=25
  • N8N_SMTP_USER=n8n@.com
  • N8N_SMTP_PASS=fewgerhrnztr
  • N8N_SMTP_SENDER=n8n-2@.com
  • N8N_SMTP_SSL=false
  • N8N_RESTRICT_FILE_ACCESS_TO=/data/windows
    labels:
  • “com.centurylinklabs.watchtower.enable=true”
    networks:
  • proxy-network

volumes:
n8n-server_n8n_data:
external: true
npm_data:
npm_letsencrypt: