"EBADF: bad file descriptor, write" error in Write File to Disk node with append option after upgrading from 2.0.2 to 2.1.2

Describe the problem/error/question

Since upgrading to 2.1.2 from 2.0.2 the Write File to Disk node is throwing a EBADF: bad file descriptor, write error when trying to append to files.

This worked before the upgrade and the path IS writable by configuring both of these settings:

  N8N_RESTRICT_FILE_ACCESS_TO: "/mnt/data/"
  N8N_BLOCK_FILE_PATTERNS: "" # allow access to .git

What is the error message (if any)?

EBADF: bad file descriptor, write

Please share your workflow

Share the output returned by the last node

{
  "errorMessage": "EBADF: bad file descriptor, write",
  "errorDetails": {
    "rawErrorMessage": [
      "EBADF: bad file descriptor, write"
    ],
    "httpCode": "EBADF"
  },
  "n8nDetails": {
    "nodeName": "Read/Write Files from Disk",
    "nodeType": "n8n-nodes-base.readWriteFile",
    "nodeVersion": 1.1,
    "operation": "write",
    "itemIndex": 0,
    "time": "12/23/2025, 12:23:26 PM",
    "n8nVersion": "2.1.2 (Self Hosted)",
    "binaryDataMode": "filesystem",
    "stackTrace": [
      "NodeApiError: EBADF: bad file descriptor, write",
      "    at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_8da18263ca0574b0db58d4fefd8173ce/node_modules/n8n-nodes-base/nodes/Files/ReadWriteFile/actions/write.operation.ts:130:10)",
      "    at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_8da18263ca0574b0db58d4fefd8173ce/node_modules/n8n-nodes-base/nodes/Files/ReadWriteFile/ReadWriteFile.node.ts:69:17)",
      "    at WorkflowExecute.executeNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_ec37920eb95917b28efaa783206b20f3/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1045:8)",
      "    at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_ec37920eb95917b28efaa783206b20f3/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1226:11)",
      "    at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_ec37920eb95917b28efaa783206b20f3/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1662:27",
      "    at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@file+packages+core_@[email protected]_@[email protected]_ec37920eb95917b28efaa783206b20f3/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:2274:11"
    ]
  }
}

Information on your n8n setup

  • n8n version: 2.1.2
  • Database (default: SQLite): PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main): not set, so default from official Docker image
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Debian Linux 13.2

Similar issue here - but only occurs when append is turned to on.

It’s a bug. Looks like the devs are opening files in write mode instead of append mode in the code somewhere.

I went to github to open an issue and someone already beat me to it: