langflow-ai/langflow · warning · HTTPException

File size is larger than the maximum file size {max_file_siz

Error message

File size is larger than the maximum file size {max_file_size_upload}MB.

What it means

HTTP 413 from POST /files/upload/{flow_id} when file.size exceeds max_file_size_upload (interpreted as MB, multiplied by 1024*1024). This is the configured upload ceiling from settings; the message includes the active limit so the client knows the bound. Note the check uses the declared UploadFile size, checked before reading the body.

Source

Thrown at src/backend/base/langflow/api/v1/files.py:108

    settings_service: Annotated[SettingsService, Depends(get_settings_service)],
) -> UploadFileResponse:
    # Writing a file to a flow's storage is a flow mutation: enforce WRITE so
    # the external access ceiling (e.g. a "viewer") cannot upload via this route.
    await ensure_flow_permission(
        current_user,
        FlowAction.WRITE,
        flow_id=flow.id,
        flow_user_id=flow.user_id,
        workspace_id=flow.workspace_id,
        folder_id=flow.folder_id,
    )
    try:
        max_file_size_upload = settings_service.settings.max_file_size_upload
    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e)) from e

    if file.size > max_file_size_upload * 1024 * 1024:
        raise HTTPException(
            status_code=413, detail=f"File size is larger than the maximum file size {max_file_size_upload}MB."
        )

    # Authorization handled by get_flow dependency
    try:
        file_content = await file.read()
        timestamp = datetime.now(tz=timezone.utc).astimezone().strftime("%Y-%m-%d_%H-%M-%S")
        file_name = file.filename or hashlib.sha256(file_content).hexdigest()
        full_file_name = f"{timestamp}_{file_name}"
        folder = str(flow.id)
        await storage_service.save_file(flow_id=folder, file_name=full_file_name, data=file_content)
        return UploadFileResponse(flow_id=str(flow.id), file_path=f"{folder}/{full_file_name}")
    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e)) from e


@router.get("/download/{flow_id}/{file_name}")
async def download_file(

View on GitHub (pinned to 976ec789d2)

Solutions

  1. Set LANGFLOW_MAX_FILE_SIZE_UPLOAD=<larger MB> and restart the backend, then retry
  2. Split or compress the file below the reported limit before upload
  3. If behind a reverse proxy, also raise the proxy's client_max_body_size so the 413 comes from Langflow with this message rather than nginx

Example fix

# before
LANGFLOW_MAX_FILE_SIZE_UPLOAD=100  # file is 250MB -> 413

# after
LANGFLOW_MAX_FILE_SIZE_UPLOAD=500
# restart langflow
Defensive patterns

Strategy: validation

Validate before calling

import os

def within_upload_limit(file_path: str) -> bool:
    limit_mb = int(os.environ.get("LANGFLOW_MAX_FILE_SIZE_UPLOAD", 100))
    return os.path.getsize(file_path) <= limit_mb * 1024 * 1024

Try / catch

try:
    client.post(f"/files/upload/{flow_id}", files=files).raise_for_status()
except HTTPError as e:
    if e.response.status_code == 413:
        split_file_or_raise_limit(files)

Prevention

When it happens

Trigger: Uploading any file larger than LANGFLOW_MAX_FILE_SIZE_UPLOAD MB (default typically 100MB) to a flow you own; large PDFs/datasets for document loaders; raising the setting but not restarting the backend.

Common situations: Feeding big knowledge-base files; users hitting the default cap on self-hosted instances; env var typo (wrong name) so the old limit still applies.

Related errors


AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14). Data as JSON: /api/errors/70e25056ed8bd49f. Report an issue: GitHub.