{"record":{"id":"3a54ee263889d859","repo":"n8n-io/n8n","slug":"failed-to-write-binary-file-id-because-its-size","errorCode":null,"errorMessage":"Failed to write binary file ${id} because its size of ${roundedSize} MB exceeds the max size limit of ${maxFileSizeMb} MB set for `database` mode. Consider increasing `N8N_BINARY_DATA_DATABASE_MAX_FILE_SIZE` up to 1 GB, or using S3 storage mode if you require writes larger than 1 GB.","messagePattern":"Failed to write binary file (.+?) because its size of (.+?) MB exceeds the max size limit of (.+?) MB set for `database` mode\\. Consider increasing `N8N_BINARY_DATA_DATABASE_MAX_FILE_SIZE` up to 1 GB, or using S3 storage mode if you require writes larger than 1 GB\\.","errorType":"exception","errorClass":"FileTooLargeError","httpStatus":null,"severity":"error","filePath":"packages/cli/src/binary-data/database.manager.ts","lineNumber":38,"sourceCode":"\t\tprivate readonly config: BinaryDataConfig,\n\t) {}\n\n\tasync init() {\n\t\t// managed centrally by typeorm\n\t}\n\n\tasync store(\n\t\tlocation: BinaryData.FileLocation,\n\t\tbufferOrStream: Buffer | Readable,\n\t\tmetadata: BinaryData.PreWriteMetadata,\n\t) {\n\t\tconst buffer = await binaryToBuffer(bufferOrStream);\n\t\tconst fileSizeBytes = buffer.length;\n\t\tconst fileSizeMb = fileSizeBytes / (1024 * 1024);\n\t\tconst fileId = uuid();\n\n\t\tif (fileSizeMb > this.config.dbMaxFileSize) {\n\t\t\tthrow new FileTooLargeError({\n\t\t\t\tfileSizeMb,\n\t\t\t\tmaxFileSizeMb: this.config.dbMaxFileSize,\n\t\t\t\tfileId,\n\t\t\t\tfileName: metadata.fileName,\n\t\t\t});\n\t\t}\n\n\t\tconst { sourceType, sourceId } = this.toSource(location);\n\n\t\tawait this.repository.insert({\n\t\t\tfileId,\n\t\t\tsourceType,\n\t\t\tsourceId,\n\t\t\tdata: buffer,\n\t\t\tmimeType: metadata.mimeType ?? null,\n\t\t\tfileName: metadata.fileName ?? null,\n\t\t\tfileSize: fileSizeBytes,\n\t\t});","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/binary-data/database.manager.ts#L20-L56","documentation":"DatabaseManager.store throws FileTooLargeError when binary data storage mode is 'database' and the incoming buffer exceeds N8N_BINARY_DATA_DATABASE_MAX_FILE_SIZE (default 250 MB, max 1 GB). The error message names the file id, size, limit, and suggests raising the env var or switching to S3.","triggerScenarios":"A node writes binary data (store()) while BinaryDataConfig.mode is 'database' and the assembled buffer's size in MB > config.dbMaxFileSize.","commonSituations":"Default DB mode with a node downloading/producing large attachments; default 250 MB limit hit by a video/PDF/data export node; ingestion pipeline without object storage configured.","solutions":["Switch binary data mode to S3: set N8N_BINARY_DATA_MODE=s3 and configure N8N_EXTERNAL_STORAGE_* credentials.","Raise the limit up to 1 GB via N8N_BINARY_DATA_DATABASE_MAX_FILE_SIZE (note DB bloat/perf cost).","Stream or chunk large payloads, or filter/compress before storing."],"exampleFix":"# before\nN8N_BINARY_DATA_MODE=database\nN8N_BINARY_DATA_DATABASE_MAX_FILE_SIZE=250\n\n# after\nN8N_BINARY_DATA_MODE=s3\nN8N_EXTERNAL_STORAGE_S3_BUCKET=my-bucket\nN8N_EXTERNAL_STORAGE_S3_REGION=us-east-1","handlingStrategy":"validation","validationCode":"// Before storing, check the configured DB limit\nconst limitMb = config.dbMaxFileSize; // from BinaryDataConfig\nif (buffer.length / (1024 * 1024) > limitMb) { /* use S3 path or reject */ }","typeGuard":"function isFileTooLargeError(error: unknown): boolean {\n  return error instanceof Error && error.constructor.name === 'FileTooLargeError';\n}","tryCatchPattern":"try {\n  await binaryDataManager.store(location, buffer, metadata);\n} catch (e) {\n  if (isFileTooLargeError(e)) { /* fall back to S3 or surface size limit to user */ }\n  else throw e;\n}","preventionTips":["Use S3 mode for any pipeline that may exceed 250 MB per file.","Raise N8N_BINARY_DATA_DATABASE_MAX_FILE_SIZE (max 1 GB) only if DB bloat is acceptable.","Cap inbound payload size upstream (webhook/node config)."],"tags":["binary-data","storage","configuration","database-mode"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}