# Bad Request: file is too big — Telegram bot file size limits and how to get around them

> Bad Request: file is too big means the bot called getFile for a file over the Bot API's 20 MB download limit. Request Entity Too Large (413) is the upload side: a file uploaded over the 50 MB limit. Resend by file_id, which has no limit, compress or split the file, or run a Local Bot API Server, which downloads without a size limit and uploads up to 2000 MB.

Source: https://livops.dev/en/guides/error-telegram-file-is-too-big

By Livops team, the people who build and run Livops. Updated 1 December 2026.

The download error, as the Bot API returns it for `getFile`[3]:

```text
{"ok":false,"error_code":400,"description":"Bad Request: file is too big"}
```

The upload error comes back with HTTP status 413, `Request Entity Too Large`, which aiogram documents as the error for a file that is too large to send[5][6]. Each library wraps them in its own class:

| Library | getFile over 20 MB | Upload over the limit (413) |
| --- | --- | --- |
| aiogram 3 | `TelegramBadRequest: Telegram server says - Bad Request: file is too big`[5][6] | `TelegramEntityTooLarge` for HTTP status 413, with a link to Telegram's "Sending files" section[5][6] |
| python-telegram-bot | `telegram.error.BadRequest: File is too big`[8][9] | `telegram.error.NetworkError`, as 413 has no class of its own[8][9] |
| grammY | `GrammyError: Call to 'getFile' failed! (400: Bad Request: file is too big)`[11] | `GrammyError` with `error_code` 413, or `HttpError` if the answer is not JSON[11][12] |
| Telegraf | `TelegramError: 400: Bad Request: file is too big`[13] | `TelegramError` with `code` 413 when the answer is JSON[13][14] |

This page gives Telegram's file size limits in Telegram's own words, the causes of both errors, and the ways around them — `file_id`, links, compression, and a Local Bot API Server with what it takes to run one. It ends with where large files belong on Livops.

## The limits, as Telegram states them

On Telegram's cloud Bot API, `https://api.telegram.org`:

| What the bot does | Limit |
| --- | --- |
| Download a file with `getFile` | 20 MB[1] |
| Send a file by `file_id` (already on Telegram's servers) | No limit[1] |
| Send a file by HTTP URL (Telegram downloads it) | 5 MB for photos, 20 MB for other content[1] |
| Upload a file with `multipart/form-data` | 10 MB for photos, 50 MB for other files[1] |
| `sendDocument`, `sendVideo`, `sendAudio`, `sendAnimation`, `sendVoice` | Up to 50 MB; Telegram says this may change[1] |
| `sendPhoto` | At most 10 MB; width and height together at most 10000[1] |

With a **Local Bot API Server** the bot can download files without a size limit, upload files up to 2000 MB, and upload by local path with the `file://` scheme[1].

Two details. Sending by URL has conditions of its own: the file must have the correct MIME type, and for `sendDocument` it currently works only for PDF and ZIP files[1]. And the download check in the open-source Bot API server is `20 << 20` bytes, which is 20,971,520[3][4].

## Causes, most common first

### 1. The bot downloads what users send

A user can send the bot a video or a document far larger than 20 MB, and the bot receives it like any other message. Calling `getFile` on it — directly, or through a helper such as aiogram's `bot.download()` — fails with `file is too big`. The server checks the expected size before downloading and stops a download that grows past the limit[3].

### 2. The bot uploads a file it made

A report, an export, a rendered video or a backup grows past 50 MB, and `sendDocument` or `sendVideo` with an uploaded file is refused with 413. Photos have a lower limit of their own, 10 MB[1].

### 3. Sending by URL with a large or unsupported file

Telegram fetches the URL itself, and its limit there is lower than for uploads: 20 MB, or 5 MB for photos[1]. A `sendDocument` by URL for a file that is not PDF or ZIP may fail as well, whatever its size[1].

## How to fix it

### Check `file_size` before you call `getFile`

`Document`, `Video` and the other file objects carry an optional `file_size` in bytes[1]. Check it, and answer the user instead of failing:

```python
# aiogram 3
LIMIT = 20 * 1024 * 1024

@router.message(F.document)
async def on_document(message: Message, bot: Bot):
    doc = message.document
    if doc.file_size and doc.file_size > LIMIT:
        await message.answer("This file is over 20 MB, which bots can't download. Please send a smaller one or a link.")
        return
    await bot.download(doc, destination=f"downloads/{doc.file_unique_id}")
```

```ts
// grammY
const LIMIT = 20 * 1024 * 1024;

bot.on("message:document", async (ctx) => {
  const doc = ctx.message.document;
  if ((doc.file_size ?? 0) > LIMIT) {
    return ctx.reply("This file is over 20 MB, which bots can't download. Please send a smaller one or a link.");
  }
  const file = await ctx.getFile();
  // ...
});
```

`file_size` is optional, so keep the error handling below for the files that come without it.

### Resend by `file_id` instead of downloading and uploading

If the goal is to pass the file on — to a channel, a group, another user, or back later — do not download it at all. A file that is already on Telegram's servers can be sent by its `file_id` with no size limit[1]. Save the `file_id` from the incoming message, or from the `Message` your first upload returned, and use it next time. Two rules apply: the type cannot change on resend (a video stays a video), and a `file_id` belongs to one bot and does not work in another[1].

### Send a link instead of the file

For a file the bot made, put it in storage and send the user a link in the message. Nothing passes through the Bot API, so its limits do not apply. Sending by URL, where Telegram downloads the file for you, helps only up to 20 MB (5 MB for photos)[1].

### Compress or split

Re-encode a video at a lower bitrate, shrink images before `sendPhoto`, or zip a report. For archives or logs that will not shrink enough, split them into parts under 50 MB and send each with `sendDocument`. Photos are capped at 10 MB[1]; a large image can go as a document instead.

### Run a Local Bot API Server

The server behind the Bot API is open source, and you can run it and send the bot's requests to it instead of `https://api.telegram.org`[1]. In `--local` mode it gives the bigger limits: downloads without a size limit, uploads up to 2000 MB[1][2]. What it takes:

- **Build and run it.** OpenSSL and zlib, compiled with CMake and a C++17 compiler[2].
- **Your own `api_id` and `api_hash`** from Telegram, passed as `--api-id` and `--api-hash` or `TELEGRAM_API_ID` and `TELEGRAM_API_HASH`; they are the only mandatory options[2].
- **HTTP only.** The server listens on port 8081 by default and accepts only HTTP; remote HTTPS needs a TLS termination proxy in front[2].
- **Log out of the cloud first.** Call `logOut` before moving the bot, or there is no guarantee it receives updates; after that it cannot log back in to the cloud Bot API for 10 minutes[1][2].
- **Absolute paths from `getFile`.** In local mode `file_path` is an absolute path on the server's disk, with no download step[1], so the bot must handle such paths[2] and be able to read that disk.

Then point the library at it:

| Library | Setting |
| --- | --- |
| aiogram 3 | `Bot(token, session=AiohttpSession(api=TelegramAPIServer.from_base("http://localhost:8081", is_local=True)))`[7][6] |
| python-telegram-bot | `ApplicationBuilder().base_url("http://localhost:8081/bot").base_file_url("http://localhost:8081/file/bot").local_mode(True)`[10] |
| grammY | `new Bot(token, { client: { apiRoot: "http://localhost:8081" } })`[12] |
| Telegraf | `new Telegraf(token, { telegram: { apiRoot: "http://localhost:8081" } })`[14][15] |

Telegram itself says most bots are fine on its servers[1]. A local server is worth it when large files are the point of the bot; for the occasional big file, `file_id` and links are less to run.

### Catch the error and tell the user

```python
# aiogram 3
from aiogram.exceptions import TelegramBadRequest, TelegramEntityTooLarge

try:
    await bot.download(message.document, destination=path)
except TelegramBadRequest as e:
    if "file is too big" not in e.message:
        raise
    await message.answer("That file is too big for me to download.")

try:
    await message.answer_document(FSInputFile(report_path))
except TelegramEntityTooLarge:
    await message.answer("The report is over Telegram's 50 MB limit. Here is a link instead: ...")
```

```python
# python-telegram-bot: the text starts with "File is too big", so compare in lower case
from telegram.error import BadRequest

try:
    tg_file = await context.bot.get_file(update.message.document.file_id)
except BadRequest as e:
    if "file is too big" not in e.message.lower():
        raise
    await update.message.reply_text("That file is too big for me to download.")
```

aiogram raises `TelegramBadRequest` for a 400 and `TelegramEntityTooLarge`, a network error class, for a 413[5][6]. python-telegram-bot maps 400 to `BadRequest` and drops the `Bad Request: ` prefix, capitalizing the rest; a 413 has no class of its own and becomes `NetworkError`[8][9]. grammY's `GrammyError` and Telegraf's `TelegramError` carry the code and `description`[11][13].

## On Livops

- **Where downloaded files go.** While a bot runs, its code folder is read-only. `/app/data` is the project's own disk, kept across deploys and restarts, and its path is in `DATA_DIR`; `/tmp` is wiped on every restart and deploy and holds 128 MB. Write downloads to `DATA_DIR`, not `/tmp`. See [Files and data](https://livops.dev/en/docs/files).
- **Large files belong in a bucket.** For lots of images and large files, add an S3 [storage bucket](https://livops.dev/en/docs/storage); boto3 and the AWS SDK work unchanged, and the keys are written into your services as variables. A bucket is private by default and hands out temporary signed links (presigned URLs), or can be made public with a `..._PUBLIC_URL` variable — either one is a link the bot can send instead of the file.
- **A worker for slow jobs.** Compressing a video or building a large report can run in a `worker` service in the same project, so the bot keeps answering. The disk belongs to one app and no other service sees it, so hand files between the two through a bucket. See [Cron and workers](https://livops.dev/en/docs/cron-workers).
- **Logs.** The error lines are on the project's **Logs** page; `livops logs <service> -f` follows them from the terminal ([CLI](https://livops.dev/en/docs/cli)).

A bot costs **19 credits a month** (19,000 so'm); see [Pricing](https://livops.dev/en/docs/pricing).

## Questions

**What is the maximum file size a Telegram bot can download?**

20 MB through getFile on Telegram's cloud Bot API. Anything larger gets Bad Request: file is too big. With a Local Bot API Server there is no download size limit.

**What is the maximum file size a Telegram bot can send?**

Uploaded as a file, up to 50 MB for documents, videos, audio and animations, and 10 MB for photos. By URL, Telegram fetches up to 5 MB for photos and 20 MB for other content. By file_id there is no limit. A Local Bot API Server raises uploads to 2000 MB.

**A user sent my bot a 100 MB video. Can the bot forward it?**

Yes. Forwarding, copying or resending it by its file_id has no size limit, because the file is already on Telegram's servers. What the bot cannot do on the cloud Bot API is download it, since getFile stops at 20 MB.

**Why does sending a file by URL fail even under 20 MB?**

The file at the URL must have the right MIME type, and for sendDocument sending by URL currently works only for PDF and ZIP files. Other combinations may work, but Telegram does not guarantee them.

**Is a Local Bot API Server hard to run?**

It is open source, but you build and run it yourself, with your own api_id and api_hash from Telegram, in --local mode for the bigger limits, behind a TLS proxy if it must accept HTTPS. The bot has to log out of the cloud Bot API first and cannot log back in there for 10 minutes.

**Does the 20 MB limit mean 20,000,000 bytes?**

In the open-source Bot API server the download check is 20 shifted left by 20 bits, that is 20,971,520 bytes. Leave a margin and compare against the file_size Telegram reports.

## Sources

1. [Telegram Bot API — Using a Local Bot API Server, Sending files, File, getFile, sendPhoto, sendDocument, sendVideo, logOut](https://core.telegram.org/bots/api). Checked 1 December 2026.
2. [Telegram Bot API server — README](https://github.com/tdlib/telegram-bot-api). Checked 1 December 2026.
3. [Telegram Bot API server source — telegram-bot-api/Client.cpp](https://raw.githubusercontent.com/tdlib/telegram-bot-api/master/telegram-bot-api/Client.cpp). Checked 1 December 2026.
4. [Telegram Bot API server source — telegram-bot-api/Client.h](https://raw.githubusercontent.com/tdlib/telegram-bot-api/master/telegram-bot-api/Client.h). Checked 1 December 2026.
5. [aiogram source — aiogram/exceptions.py](https://raw.githubusercontent.com/aiogram/aiogram/dev-3.x/aiogram/exceptions.py). Checked 1 December 2026.
6. [aiogram source — aiogram/client/session/base.py](https://raw.githubusercontent.com/aiogram/aiogram/dev-3.x/aiogram/client/session/base.py). Checked 1 December 2026.
7. [aiogram source — aiogram/client/telegram.py](https://raw.githubusercontent.com/aiogram/aiogram/dev-3.x/aiogram/client/telegram.py). Checked 1 December 2026.
8. [python-telegram-bot source — telegram/error.py](https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/src/telegram/error.py). Checked 1 December 2026.
9. [python-telegram-bot source — telegram/request/_baserequest.py](https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/src/telegram/request/_baserequest.py). Checked 1 December 2026.
10. [python-telegram-bot source — telegram/ext/_applicationbuilder.py](https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/src/telegram/ext/_applicationbuilder.py). Checked 1 December 2026.
11. [grammY source — src/core/error.ts](https://raw.githubusercontent.com/grammyjs/grammY/main/src/core/error.ts). Checked 1 December 2026.
12. [grammY source — src/core/client.ts](https://raw.githubusercontent.com/grammyjs/grammY/main/src/core/client.ts). Checked 1 December 2026.
13. [Telegraf source — src/core/network/error.ts](https://raw.githubusercontent.com/telegraf/telegraf/v4/src/core/network/error.ts). Checked 1 December 2026.
14. [Telegraf source — src/core/network/client.ts](https://raw.githubusercontent.com/telegraf/telegraf/v4/src/core/network/client.ts). Checked 1 December 2026.
15. [Telegraf source — src/telegraf.ts](https://raw.githubusercontent.com/telegraf/telegraf/v4/src/telegraf.ts). Checked 1 December 2026.
