How to Fix "Access to the File Is Not Allowed" in n8n 2.x (Docker)
How to Fix "Access to the File Is Not Allowed" in n8n 2.x (Docker)
This is part 1 of the n8n Troubleshooting series, practical fixes for errors you hit when self-hosting n8n.
Have you ever tried to read a file in n8n, only to get this?
1NodeApiError: Access to the file is not allowed.
I hit it while building a local AI document chatbot with n8n and Docker. The file was inside the container, and I could see it from the terminal with ls. n8n still refused to read it.
The cause turned out not to be Docker, and not file permissions. It was n8n's own file-access rule, which changed in n8n 2.0. Here is how to confirm that and fix it.
The Problem
My setup was n8n 2.44.6, self-hosted with Docker Compose. I wanted n8n to read documents from one folder so an AI assistant could search PDFs and other files.
The folder was mounted into the container and the file was there. But the Read/Write Files from Disk node failed with Access to the file is not allowed.
It looked like a volume or permissions problem. It wasn't.
Why Does This Happen?
Two separate layers decide whether n8n can read a file:
- Docker decides whether the file exists inside the container (your volume mounts).
- n8n decides which paths its file nodes are allowed to touch, through the
N8N_RESTRICT_FILE_ACCESS_TOsetting.
So a file can be perfectly visible inside the container and still be blocked by n8n.
The detail that catches people out: starting with n8n 2.0, N8N_RESTRICT_FILE_ACCESS_TO defaults to ~/.n8n-files (in the official image, /home/node/.n8n-files). If you never set the variable, n8n 2.x only lets file nodes read and write inside that one folder. On n8n 1.x a self-hosted instance could read any path the process could reach, which is why workflows that used to work can start failing after an upgrade.
What I Tested
To be sure about the cause, I reproduced it with the same image I was using, n8nio/n8n:2.44.6. I ran a Manual Trigger and a Read/Write Files from Disk node through the n8n CLI in throwaway containers, with a test folder mounted read-only:
| Configuration | File read | Result |
|---|---|---|
| Variable not set (2.x default) | /data/knowledge/test.txt | ❌ Access to the file is not allowed. |
| Variable not set (2.x default) | /home/node/.n8n-files/h.txt | ✅ Read |
N8N_RESTRICT_FILE_ACCESS_TO=/data/knowledge | /data/knowledge/test.txt | ✅ Read |
N8N_RESTRICT_FILE_ACCESS_TO=/data/knowledge;/data/reports | /data/reports/r.txt | ✅ Read |
N8N_RESTRICT_FILE_ACCESS_TO=/data/knowledge | /data/reports/r.txt | ❌ Blocked |
N8N_RESTRICT_FILE_ACCESS_TO=/data/knowledge | /home/node/.n8n-files/h.txt | ❌ Blocked |
Variable not set, folder mounted at /home/node/.n8n-files/knowledge | /home/node/.n8n-files/knowledge/test.txt | ✅ Read |
Two things in that table matter for the fix:
- Setting the variable replaces the default. Once you set it,
~/.n8n-filesis no longer allowed unless you include it in the list. - You don't have to set the variable at all if you mount your folder inside
/home/node/.n8n-files(the last row).
Step 1: Check the Docker Container
First, find your running n8n container:
1docker ps
Then confirm the file exists inside the container:
1docker exec YOUR_N8N_CONTAINER ls -l /data/knowledge
Replace YOUR_N8N_CONTAINER with your container name or ID. /data/knowledge is the example folder used throughout this post; yours may differ depending on your volume mounts.
If your file shows up, the Docker mount is working and the problem is n8n's allowlist.
Step 2: Check the n8n File-Access Setting
1docker exec YOUR_N8N_CONTAINER \
2 printenv N8N_RESTRICT_FILE_ACCESS_TO
- No output means the variable isn't set, so on n8n 2.x only
/home/node/.n8n-filesis allowed. That is the usual cause of this error. - A list of paths means only those directories are allowed. If your folder isn't in the list, n8n blocks it.
Step 3: Update the Docker Compose Configuration
You have two options.
Option A: Allow your folder with N8N_RESTRICT_FILE_ACCESS_TO
Open your docker-compose.yml, find the n8n service, and add or update:
1services:
2 n8n:
3 volumes:
4 - /path/on/your/computer:/data/knowledge:ro
5 environment:
6 - N8N_RESTRICT_FILE_ACCESS_TO=/data/knowledge
Replace /path/on/your/computer with the real folder on your machine.
Important: if your Compose file already has volumes or environment entries for n8n, merge these lines into them. Don't replace your existing configuration.
What each part does:
/path/on/your/computeris the folder on your machine./data/knowledgeis where that folder appears inside the container.:romounts it read-only, so a workflow can't modify or delete your original documents.N8N_RESTRICT_FILE_ACCESS_TOtells n8n that file nodes may use that directory.
To allow more than one directory, separate them with semicolons:
1 environment:
2 - N8N_RESTRICT_FILE_ACCESS_TO=/data/knowledge;/data/reports;/home/node/.n8n-files
Include /home/node/.n8n-files in the list if any existing workflows still read or write there. As the test above shows, setting the variable removes the default.
Option B: Mount your folder inside .n8n-files (no variable needed)
If you'd rather keep n8n's default, mount the folder under the directory n8n 2.x already allows:
1services:
2 n8n:
3 volumes:
4 - /path/on/your/computer:/home/node/.n8n-files/knowledge:ro
Then use /home/node/.n8n-files/knowledge/... as the path in your workflow.
Step 4: Recreate the Container
Environment variables are fixed when a container is created, so docker restart won't pick up the change. Recreate it instead:
1docker compose up -d
Compose notices that the n8n service's configuration changed and recreates that container. If you're on the older standalone tool, the command is docker-compose up -d. Adding --force-recreate also works, but it recreates every service in the file, not only n8n.
Then check again:
1docker exec YOUR_N8N_CONTAINER \
2 printenv N8N_RESTRICT_FILE_ACCESS_TO
Confirm the output contains the directory you meant to allow.
Step 5: Test the File in n8n
Open your workflow and configure the Read/Write Files from Disk node. Enter the path as it appears inside the container, for example:
1/data/knowledge/example.pdf
Replace example.pdf with your real filename. Use the container path, not the path on your computer. Inside Docker, n8n only sees the container's filesystem.
Run the node. With the allowlist set correctly, n8n reads the file.
For PDFs, reading the file gives you binary data, not text. Add an Extract from File node after it to get the document's contents.
Common Mistakes to Avoid
- Using the host path in the node.
/Users/you/Documents/report.pdfdoesn't exist inside the container. Use the mounted path, such as/data/knowledge/report.pdf. - Restarting instead of recreating.
docker restartkeeps the old environment. Usedocker compose up -d. - Forgetting that the variable replaces the default. If you set it to one folder,
~/.n8n-filesstops working until you add it back. - Allowing
/. It makes the error go away by giving every workflow access to the whole container filesystem. Allow only the folders you need. - Using commas, colons or spaces between paths. The separator is a semicolon.
Troubleshooting
Still "Access to the file is not allowed" after the change. Run the printenv command from Step 4. If it shows the old value, the container wasn't recreated, you edited a different service, or a .env file or another Compose file is overriding the variable. If it shows the right value, check that the node's path starts with exactly one of the allowed directories.
EACCES: permission denied instead. That's a different problem: the operating system, not n8n, is refusing access. The official image runs n8n as the node user (UID 1000), so that user needs read permission on the mounted files.
ENOENT: no such file or directory. The path doesn't exist inside the container. Check the volume mapping with the docker exec ... ls command from Step 1.
n8n Cloud. On n8n Cloud the node can only access paths under /home/node/, and you can't change the setting.
FAQ
Did this change in n8n 2.0?
Yes. n8n's documentation for the Read/Write Files from Disk node says that starting in n8n 2.0, N8N_RESTRICT_FILE_ACCESS_TO defaults to ~/.n8n-files. My test on 2.44.6 matched that behaviour.
Can I allow several folders?
Yes. Separate them with semicolons, for example /data/knowledge;/data/reports.
Is it safe to set the variable to /?
It works, but it lets any workflow read and write anywhere in the container, including n8n's own data. Allow specific folders instead, and mount them :ro when workflows only need to read.
Does this affect other nodes?
N8N_RESTRICT_FILE_ACCESS_TO is an instance-wide setting for file access from workflows, so if another node that reads or writes local files shows the same message, check this setting first. I only tested the Read/Write Files from Disk node.
Key Takeaways
| Lesson | Detail |
|---|---|
| Visible in Docker ≠ allowed in n8n | Volume mounts and n8n's allowlist are separate layers |
| The 2.x default is restrictive | Without the variable, only /home/node/.n8n-files is allowed |
| Setting the variable replaces the default | Add /home/node/.n8n-files back if you still use it |
| Multiple folders | Separate paths with semicolons |
| Apply changes properly | Recreate the container; a restart doesn't change environment variables |
| Use container paths | The node sees the container's filesystem, not your computer's |
| Keep it narrow | Allow specific folders, not the whole filesystem |
What's Next?
Once n8n could read my documents, I could get back to the bigger project: a local AI document assistant built with n8n, Ollama and a document search step, so I can ask questions about files in one folder and get answers based on their contents. For example:
- Find clauses in contracts
- Search across many PDF files
- Pull details out of invoices and spreadsheets
- Summarise project documents
A small configuration issue was the only thing standing between me and a much bigger automation.
This post is the first in the n8n Troubleshooting series. Have you hit this error in your own n8n setup? Tell me about it, especially if your fix was different.