n8n-io/n8n · error · FileTooLargeError

Failed to write binary file ${id} because its size of ${roun

Error message

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.

What it means

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.

Source

Thrown at packages/cli/src/binary-data/database.manager.ts:38

		private readonly config: BinaryDataConfig,
	) {}

	async init() {
		// managed centrally by typeorm
	}

	async store(
		location: BinaryData.FileLocation,
		bufferOrStream: Buffer | Readable,
		metadata: BinaryData.PreWriteMetadata,
	) {
		const buffer = await binaryToBuffer(bufferOrStream);
		const fileSizeBytes = buffer.length;
		const fileSizeMb = fileSizeBytes / (1024 * 1024);
		const fileId = uuid();

		if (fileSizeMb > this.config.dbMaxFileSize) {
			throw new FileTooLargeError({
				fileSizeMb,
				maxFileSizeMb: this.config.dbMaxFileSize,
				fileId,
				fileName: metadata.fileName,
			});
		}

		const { sourceType, sourceId } = this.toSource(location);

		await this.repository.insert({
			fileId,
			sourceType,
			sourceId,
			data: buffer,
			mimeType: metadata.mimeType ?? null,
			fileName: metadata.fileName ?? null,
			fileSize: fileSizeBytes,
		});

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Switch binary data mode to S3: set N8N_BINARY_DATA_MODE=s3 and configure N8N_EXTERNAL_STORAGE_* credentials.
  2. Raise the limit up to 1 GB via N8N_BINARY_DATA_DATABASE_MAX_FILE_SIZE (note DB bloat/perf cost).
  3. Stream or chunk large payloads, or filter/compress before storing.

Example fix

# before
N8N_BINARY_DATA_MODE=database
N8N_BINARY_DATA_DATABASE_MAX_FILE_SIZE=250

# after
N8N_BINARY_DATA_MODE=s3
N8N_EXTERNAL_STORAGE_S3_BUCKET=my-bucket
N8N_EXTERNAL_STORAGE_S3_REGION=us-east-1
Defensive patterns

Strategy: validation

Validate before calling

// Before storing, check the configured DB limit
const limitMb = config.dbMaxFileSize; // from BinaryDataConfig
if (buffer.length / (1024 * 1024) > limitMb) { /* use S3 path or reject */ }

Type guard

function isFileTooLargeError(error: unknown): boolean {
  return error instanceof Error && error.constructor.name === 'FileTooLargeError';
}

Try / catch

try {
  await binaryDataManager.store(location, buffer, metadata);
} catch (e) {
  if (isFileTooLargeError(e)) { /* fall back to S3 or surface size limit to user */ }
  else throw e;
}

Prevention

When it happens

Trigger: A node writes binary data (store()) while BinaryDataConfig.mode is 'database' and the assembled buffer's size in MB > config.dbMaxFileSize.

Common situations: 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.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/3a54ee263889d859. Report an issue: GitHub.