Unable to read/write file in local system

When trying to write/read files on local machine drive - I am getting ‘The file has changed and cannot be written.’ error.

What is the error message (if any)?

The file has changed and cannot be written.

Please share your workflow

Share the output returned by the last node

[
{
“data”: “test”
}
]

Information on your n8n setup

  • n8n version: 2.4.6
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default: own, main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): self-hosted npm
  • Operating system: Win 11

Hey guys,

So when I try to write/read files on local machine drive - I am getting ‘The file has changed and cannot be written.’ error.
I added env variables but this didn’t help.
This started after updating to 2.4.6 from 1.x.x

Please check the screenshot attached for more info.

Appreciate any help on this.

Hi @endrust !

This is expected behavior in n8n 2.x. The recommended solution is to always write to a new file instead of overwriting an existing one.

Generate a unique filename for each execution (for example, by appending a timestamp or execution ID). This avoids the file-change detection introduced in n8n 2.x, which is especially sensitive on Windows.

Example:

C:\Projects\output_{{ $execution.id }}.json

This approach reliably prevents the “The file has changed and cannot be written” error.

Hi @ tamy.santos,

Thank you for a quick reply.
I tried to use a method yousuggested but now got another error:

The file was created but its identity does not match and cannot be written.

Do you know what might be the issue?

Most likely Windows 11 is doing its thing :confused: probably permission issues that prevent n8n from writing..

Yeah, probably so @mohamed3nan
I’ve spent few hours with setting system variables but didn’t get any luck.

@endrust

What tends to work more reliably in this case is:

  • Try to write the file in one go, instead of creating it first and then writing to it later.
  • Use a temporary folder (for example C:\temp\n8n\) — this usually avoids Windows interfering with the file.
  • Avoid reusing or overwriting the same file path between executions.
  • If you can, running n8n via Docker or WSL on Windows is the most stable setup long-term.

Your filename using {{ $execution.id }} is actually fine — the problem isn’t the expression itself, but how Windows handles the file between creation and write.

Ok, will try a setup with ‘temp’ folder. If it doesn’t help, then probably will switch to docker.
Thanks @tamy.santos

1 Like

@endrust I’d appreciate it if you could mark this as the solution if it works for you.

1 Like