Local file trigger node not triggering

Describe the issue/error/question

I am attempting to react to new files being added to a directory, in order to process them through a workflow. I found the Local File Trigger node, which seems to be exactly what I need, however it does not trigger as expected.

I expect to get a file list of all the changed files that the filter catches.

What is the error message (if any)?

No error message, just the trigger not triggering (spinning forever). I can read the file contents with the Read Binary File node without issues. When checking the file parameters the updated field gets properly updated when I change the file.

Please share the workflow

Share the output returned by the last node

No data is outputted from the Local File Trigger node, however Read Binary File outputs everything correctly.

Information on your n8n setup

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

Hi,

I had this problem at first and the reason why was that i had everything stored in the “my documents folder” which n8n couldnt read properly, so I moved n8n along with all its mounts into “home” and it worked fine afterwards.

just check if the volumes are mounted and that n8n can see the files using the execute command using “ls -ls”

1 Like

@Josh-Ghazi I tried to set the Folder to Watch field to /home/node/input, instead of just /input, but that did not solve it.

I can poll the folder with ls -la /input (inside the docker container) and see the moved files and their updated timestamps, but the node itself does not trigger. The Read Binary File node still works great.

Perhaps it’s a n8n access issue or I have to set a relative path instead of an absolute one from the root? The documentation is not very clear on that and there are no example templates for this node.

Hey @Nurgak,

For the trigger node you would put the full path to the folder you want to monitor, If the container has /Input as a path it should work.

As a quick test have you tried using the execute command node and running ls /input to see if it outputs anything?

@Jon ln /input does list the files as expected.

I tested creating a file with touch /input/test.txt from inside the docker container and then the node triggered as expected, so I cannot manipulate files outside of the docker container and have the node react to it.

However, it seems I misunderstood the way the node works: I expected it to continue listening to events after being triggered, but it seems it stops after triggering once. So, beyond the fact that it doesn’t work for events outside of the docker container, it is not quite appropriate for what I intended (continuous triggering). I can probably do something similar using cron or an other method.

Hey @Nurgak,

If you use the “Execute Workflow” button it will run once as that is designed for testing your workflow in the editor. On the top right there is an “Active” toggle next to the Save button, If this is set it will then run in the background.

I would expect it to work for files that are made outside of the container if they are going into the same mounted volume, I will give that a test. It could be that the os notifiers are not triggered in the same way, I will grab a coffee and take a quick look.

Alright back with a quick test result, In my container I have /files which is a volume with the host OS path being /home/docker/n8n-files.

I have set up a quick trigger that looks for any changes in /files then I have SSH’d to my docker host ran touch /home/docker/n8n-files/file.txt and it worked as expected so I popped in a Slack node to output the workflow name, Execution ID, Event and Path then activated the workflow and created a new file, added content to the file and made some folders.

It looks like the node is working with a Linux host running the standard docker image on 195.5, Out of interest what OS are you using for your host? It would be nice to try and get to the bottom of why it isn’t working on your setup.

To be complete the workflow below is what I have used.

@Jon Sorry for the late reply. I’m running macOS Monterey 12.6 with Rancher Desktop 1.5.1. Must be an OS-specific issue then, perhaps?

Hey @Nurgak,

It could be, I don’t have rancher desktop installed but I can give it a test later this week and see if I have the same issue there.

@Jon Perhaps it’s not related to n8n, rather my specific setup with docker. The library used to detect files changes in n8n (Chokidar, as seen from here) seems to have this issue already reported in their repository.

It looks like if polling is enabled it would work, but this is not an option in the local file trigger node right now (also not very elegant).

Hey @Nurgak,

That does look like it could be the case so maybe it is only an issue from a Mac host. The good news is in theory I should be able to reproduce that. I am surprised a bug like that from 2020 is still an issue.

Came here for the same issue. n8n in a Docker container on MacOS works fine with local file trigger. n8n in a container on Windows 10 doesn’t react to any file changes. An ls with the “Execute command” or “Read binary file” works fine.

To test further I logged into the container and created a simple JS file with a simple Chokidar watch folder. The result was the same: Nothing was triggered. When I added “usePolling: true” to the watch parameters then Chokidar behaved as expected. How can I add “usePolling: true” to the local file trigger? Or is there maybe another solution?