# starlette.datastructures.UploadFile: 413 Request Entity Too Large

- **ID:** `python/fastapi-upload-file-size-error`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The uploaded file exceeds the server's maximum allowed size, often due to default limits in the web server or framework.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Configure the server limit, e.g., in Uvicorn: uvicorn app:app --limit-max-request-size 10485760
   ```
2. **** (95% success)
   ```
   Check file size before processing: if file.size > MAX_SIZE:\n    raise HTTPException(413)
   ```

## Dead Ends

- **** — Reading the entire file into memory before checking size can cause memory issues. (80% fail)
- **** — Increasing the limit globally may affect other parts of the app. (60% fail)
