"Access Denied" for Mounted Volume on Synology Docker - Watch Directory Trigger

Hello n8n community,

I am self-hosting n8n (version 1.92.2) on a Synology NAS using Docker Compose. My goal is to create a workflow that automatically processes PDF files added to a specific folder on my Synology. The workflow should:

  1. Use the “Watch Directory” trigger to detect new PDF files in /volume1/knowledge_base/research_data (which is mounted to /home/node/.n8n/research_data in the n8n container).
  2. Read the content of the PDF file using the “Read/Write File” node.
  3. Send the PDF content to a Tesseract OCR API running in another Docker container (tesseractshadow/tesseract4re on port 8080).
  4. Process the OCR’d text with ChatGPT.

The “Watch Directory” trigger seems to be working intermittently (or not at all consistently). When it does trigger and the workflow proceeds to the “Read/Write File” node, I consistently encounter the following error:

Access to the file is not allowed. Error details: NodeApiError: Access to the file is not allowed.

Here’s a summary of the steps I have taken to troubleshoot this issue:

  • Volume Mount: The volume mapping in my docker-compose.yml seems correct:`YAMLvolumes:
    • /volume1/docker/n8n:/home/node/.n8n
    • /volume1/knowledge_base/research_data:/home/node/.n8n/research_data`
  • File Permissions on Synology Host: I have extensively adjusted the permissions of the /volume1/knowledge_base/research_data folder and the PDF files within it on my Synology NAS. I have tried:
    • Granting read and write permissions to “everyone” (chmod -R a+rw).
    • Changing the owner of the folder and files to the UID of the node user inside the n8n container (UID 1000) and the users group (GID 100).
    • Ensuring the “users” group has read permissions (chmod -R g+r).
  • User Mapping in docker-compose.yml: I have tried explicitly mapping the node user inside the container to the UID and GID on the host:YAMLuser: "1000:100"
  • Testing with “Execute Command” in n8n: I tried to list and read the files from within the n8n container using the “Execute Command” node with ls -l /home/node/.n8n/research_data and cat /home/node/.n8n/research_data/[filename].pdf, but encountered “Permission denied” errors initially. After adjusting host permissions, ls -l shows the files, but cat still gives permission errors.
  • “Watch Directory” Trigger Behavior: The trigger sometimes doesn’t seem to detect new files. I’ve tried different polling intervals and ensured the workflow is active.
  • Work-around with “Schedule Trigger” + “List Files”: As a temporary measure, I’ve implemented a workflow that uses a “Schedule Trigger” to periodically list files in the directory and process the newest one. This works, indicating that n8n can access the files, but the “Watch Directory” trigger is unreliable.

It seems there might be a specific issue related to how Docker on Synology handles volume permissions or how the “Watch Directory” trigger interacts with the Synology filesystem within the Docker container.

Has anyone else experienced similar issues with “Access denied” errors for mounted volumes in n8n running on Docker on a Synology NAS? Are there any specific configurations or work-arounds that I might be missing?

Any help or insights would be greatly appreciated!

Cheers,

Jacco

You probably need to set a different path inside the container for your research data directory. /volume1/knowledge_base/research_data:/home/node/.n8n/research_data maps inside the …/.n8n/… directory which is blocked by the default value (true) of environment variable N8N_BLOCK_FILE_ACCESS_TO_N8N_FILES

Either change the path where the volume is mapped to something else like /volume1/knowledge_base/research_data:/research_data or (less secure, not recommended) set N8N_BLOCK_FILE_ACCESS_TO_N8N_FILES to false.

I couldn’t say why this ever works (maybe there are places in the n8n code where they forgot to check whether N8N_BLOCK_FILE_ACCESS_TO_N8N_FILES is true or false), but the env var setting is the best explanation I know of for why it would give you access errors.

1 Like

Thanks for this!!

I did the same on Synology already and confirm /volume1/knowledge_base/research_data:/research_data is the correct way to set up additional mounts. you will be able to query either with watch folder or with a direct cli command (e.g. find) the files you need. check permissions as well on DSM side in case you have access issues.

2 Likes

cool thanks for this info :slight_smile:

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