Skip to content

readWriteFile node fails with "not writable" error when using relative file paths despite correct permissions #23646

Description

@priyansh-lissun

Describe the problem/error/question

The "Read/Write Files from Disk" node throws a "not writable" error when attempting to write to /home/node/token.txt, even though:
The file exists with 666 permissions and is owned by node:node
The directory has 777 permissions and is owned by node:node
Manual write tests using echo "test" > token.txt work perfectly fine from within the container
The n8n process (running as node user) has full access to write to the file
The permission check in the node appears to be incorrectly failing despite the file being fully writable.

What is the error message (if any)?

The file "/home/node/token.txt" is not writable.

NodeApiError: The file "/home/node/token.txt" is not writable. at ExecuteContext.execute
(/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@aws-sdk+credential-provider@3.808.0_asn1.js@5_8da18263ca0574b0db58d4fefd8173ce/node_modules/n8n-nodes-base/nodes/Files/ReadWriteFile/actions/write.operation.ts:33:30)

Please share your workflow/screenshots/recording

{
  "nodes": [
    {
      "parameters": {
        "method": "POST",
        "url": "https://your-api-domain.com/auth/login",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleOAuth2Api",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "key",
              "value": "YOUR_API_KEY_HERE"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        432,
        112
      ],
      "id": "da887b8e-ce03-4bb8-b1a1-43f07926066e",
      "name": "HTTP Request",
      "credentials": {
        "googleOAuth2Api": {
          "id": "YOUR_CREDENTIAL_ID",
          "name": "Google OAuth Account"
        }
      }
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 2,14 * * *"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        80,
        112
      ],
      "id": "d885414a-cf8d-40ae-9ddd-efdf0df6e7ea",
      "name": "Schedule Trigger"
    },
    {
      "parameters": {
        "operation": "write",
        "fileName": "./token.txt",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        1328,
        112
      ],
      "id": "0a8b7ad2-f4b7-4e03-afc6-f8068e547fc7",
      "name": "Read/Write Files from Disk"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "be0a5380-5e0b-4916-b286-45b29bb10612",
              "name": "jwtToken",
              "value": "={{ $json.jwtToken }}",
              "type": "string"
            },
            {
              "id": "24b89deb-75b1-49b7-8f8d-0f250dad84de",
              "name": "userId",
              "value": "={{ $json.user.id }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        752,
        112
      ],
      "id": "e731a816-f063-406b-945f-085a025ed60a",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "operation": "toText",
        "sourceProperty": "jwtToken",
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        1024,
        112
      ],
      "id": "443a7a9a-bf7b-424b-bd23-f7411128258b",
      "name": "Convert to File"
    },
    {
      "parameters": {
        "operation": "write",
        "fileName": "./id.txt",
        "options": {}
      },
      "type": "n8n-nodes-base.readWriteFile",
      "typeVersion": 1,
      "position": [
        1344,
        448
      ],
      "id": "c7147cbd-01e8-4809-8260-e3de559c27aa",
      "name": "Read/Write Files from Disk1"
    },
    {
      "parameters": {
        "operation": "toText",
        "sourceProperty": "userId",
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        1040,
        448
      ],
      "id": "e148fda9-2e63-4cb3-aeb0-bcd241a5afbc",
      "name": "Convert to File1"
    }
  ],
  "connections": {
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          },
          {
            "node": "Convert to File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File1": {
      "main": [
        [
          {
            "node": "Read/Write Files from Disk1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Share the output returned by the last node

{
"error": "The file "/home/node/token.txt" is not writable."
}

Debug info

  • n8n version: 2.1.4 (Self Hosted)
  • Node type: n8n-nodes-base.readWriteFile
  • Node version: 1 (Latest version: 1.1)
  • Environment: Docker container (Alpine Linux)
  • File path used: /home/node/token.txt (absolute path)

Permission verification from inside container:

$ ls -la token.txt-rw-rw-rw-    1 node     node             0 Dec 26 06:55 token.txt$ ls -lad /home/nodedrwxrwxrwx    1 node     node          4096 Dec 26 06:30 /home/node$ echo "test write" > token.txt && cat token.txttest write

#Additional context:

  • Manual write operations to the file succeed without any issues
  • The n8n process is running as the node user (PID 7)
  • The error occurs during the permission check phase, before any actual write attempt
  • Workaround: Using "Execute Command" node with sh -c 'echo "content" > /home/node/token.txt' works fine

core

  • n8nVersion: 2.1.4
  • platform: docker (self-hosted)
  • nodeJsVersion: 22.21.1
  • nodeEnv: production
  • database: postgres
  • executionMode: regular
  • concurrency: -1
  • license: enterprise (production)

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: filesystem

pruning

  • enabled: true
  • maxAge: 336 hours
  • maxCount: 10000 executions

client

  • userAgent: mozilla/5.0 (macintosh; intel mac os x 10_15_7) applewebkit/537.36 (khtml, like gecko) chrome/143.0.0.0 safari/537.36
  • isTouchDevice: false

Generated at: 2025-12-26T06:58:44.329Z}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions