# Bad Request: failed to get HTTP URL content — Telegram bot error and how to fix it

> Bad Request: failed to get HTTP URL content means your bot sent a photo, document or video as a URL, and Telegram's servers could not download it. The link points at localhost or a private network, needs a login, has expired, or does not answer with the file. Upload the file yourself with multipart/form-data, which aiogram, python-telegram-bot, grammY and Telegraf all support, or give Telegram a public direct link.

Source: https://livops.dev/en/guides/error-telegram-failed-to-get-http-url-content

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

The error, as the Telegram Bot API returns it[2]:

```text
{"ok":false,"error_code":400,"description":"Bad Request: failed to get HTTP URL content"}
```

Each library wraps it in its own words:

| Library | What you see |
| --- | --- |
| aiogram 3 | `TelegramBadRequest: Telegram server says - Bad Request: failed to get HTTP URL content`[7][8] |
| python-telegram-bot | `telegram.error.BadRequest: Failed to get http url content`[10][11] |
| grammY | `GrammyError: Call to 'sendPhoto' failed! (400: Bad Request: failed to get HTTP URL content)`[14] |
| Telegraf | `TelegramError: 400: Bad Request: failed to get HTTP URL content`[16] |

python-telegram-bot drops the `Bad Request: ` prefix and runs the rest through Python's `capitalize()`, which also lowercases `HTTP URL`[10]; search your logs case-insensitively. This page explains who downloads the URL and why it fails there, the URL rules Telegram sets, and the fixes in aiogram, python-telegram-bot, grammY and Telegraf, ending with how to give Telegram a working link on Livops.

## What does the error mean?

`sendPhoto`, `sendDocument`, `sendVideo` and the other send methods take a file in three ways: a `file_id` of a file already on Telegram's servers, an **HTTP URL** for Telegram to download, or a new file uploaded with `multipart/form-data`[1]. With a URL, "Telegram will download and send the file"[1]: the Bot API server passes your string on as a remote file[2], a string with a dot in it is read as a URL[5], and for a photo TDLib hands Telegram the URL itself, as an external photo[4]. Your bot never touches the file. Telegram's servers fetch it, from wherever they are, with none of your bot's cookies, headers or network access.

When that fetch fails, Telegram answers `WEBPAGE_CURL_FAILED`, which its API reference describes as a failure while fetching the webpage with cURL[3]. The Bot API server translates it into `Failed to get HTTP URL content`, lowercases the first letter and puts `Bad Request: ` in front[2]. The message says the download failed, not why: it is a fixed text, with no HTTP status or network error in it[2].

### The same family, different messages

All of these come from the same three-way choice of `file_id`, URL or upload:

| Message | Where it comes from |
| --- | --- |
| `failed to get HTTP URL content` | Telegram's `WEBPAGE_CURL_FAILED`: fetching the URL failed[2][3] |
| `wrong type of the web page content` | Telegram's `WEBPAGE_MEDIA_EMPTY`, "Webpage media empty": something was fetched, but it is not media Telegram can send[2][3] |
| `wrong HTTP URL specified` | Telegram's `EXTERNAL_URL_INVALID` ("External URL invalid") or `WC_CONVERT_URL_INVALID`[2][3] |
| `invalid file HTTP URL specified: ...` | TDLib could not parse the string as a URL at all; the reason follows the colon[5] |
| `can't upload file by URL` | The Bot API server's wording for a TDLib error, `File generation failed`[2] |
| `wrong file identifier/HTTP URL specified` | Telegram reported empty media, for a `file_id` or a URL alike[6]; see [its own page](https://livops.dev/en/guides/error-telegram-wrong-file-identifier) |

A broken `file_id` never gives `failed to get HTTP URL content`: a string without a dot is decoded as a `file_id`, not fetched[5]. If you see this message, Telegram was trying to download a link.

## Causes, most common first

### 1. The link is not on the public internet

Telegram's servers can reach only what the whole internet can reach. These all work from your laptop or your server and fail for Telegram:

- `http://localhost:8000/media/photo.jpg`, `http://127.0.0.1/...`, or the bot's own development server;
- a private address such as `10.x.x.x`, `172.16.x.x` to `172.31.x.x` or `192.168.x.x`, or a hostname that exists only inside your Docker network or office;
- a server behind a VPN, or a firewall that lets in only your own IP addresses.

**Fix:** upload the file instead (below). Serving it over HTTP just so Telegram can download it adds a public endpoint you do not need.

### 2. The link needs a login

The file is behind a session cookie, an `Authorization` header, basic auth, or a token your bot would add. Telegram sends none of them, so the server answers with a login page or an error instead of the file.

**Fix:** download it in the bot, where you can send the header, and upload it. aiogram's `URLInputFile` takes `headers` for exactly this[9].

### 3. The signed link has expired

A presigned link to an object in S3 or a compatible storage "remains valid for a limited period of time which is specified when the URL is generated"[18]. A bot that builds the link early — when it queues the message, or once at start — and sends it later can pass Telegram a link that no longer works. **Fix:** generate the link right before the send call, with an expiry of a few minutes rather than seconds, or upload the object's bytes.

### 4. The server answers, but not with the file

A share page of a cloud drive, a link shortener's preview, a "click to download" page or a bot-check page answers `200` with HTML. Telegram wants the file itself, with the correct MIME type: for example `audio/mpeg` for `sendAudio`[1]. Depending on what Telegram got, this ends in this error or in `wrong type of the web page content`[2][3].

**Fix:** use the direct file link, and check what it really returns (see [How to check a URL](#how-to-check-a-url-before-you-send-it)).

### 5. The file or the method does not fit the URL rules

Sending by URL has its own rules, stricter than uploading[1]:

| Rule | By URL | Uploaded |
| --- | --- | --- |
| Photo size | 5 MB at most | 10 MB at most |
| Other files | 20 MB at most | 50 MB at most |
| `sendDocument` | currently only `.PDF` and `.ZIP` files | any file |
| `sendVoice` | `audio/ogg`, no more than 1 MB; 1–20 MB voice notes are sent as files | — |
| `sendVideoNote`, live photos | not supported by URL | supported |
| `thumbnail` | ignored unless the file itself is uploaded | JPEG under 200 kB, at most 320 px a side |

Telegram adds that other configurations may work, but it can't guarantee that they will[1]. The documentation gives the limits but not the error each one produces, so when a URL fails, check its size and type before anything else. A photo that downloads fine can still be refused for its shape: see [PHOTO_INVALID_DIMENSIONS](https://livops.dev/en/guides/error-telegram-photo-invalid-dimensions). For files above the upload limits, see [file is too big](https://livops.dev/en/guides/error-telegram-file-is-too-big).

### 6. Redirects, hotlink protection, a slow server

The Bot API documentation does not say whether Telegram follows redirects, which `User-Agent` it sends, or how long it waits for an answer. So treat each as a risk: a link that redirects through a tracker or a login, a site that serves images only to its own pages or to browsers, and a server that takes a long time to start sending can each fail for Telegram while working in a browser. **Fix:** a direct link that answers `200` at once, or an upload.

## How to fix it

### Upload the file instead of sending the link

This works for every cause above, because the bot does the download, with its own headers and network, and Telegram receives the bytes. The upload limits apply: 10 MB for photos, 50 MB for other files[1].

**aiogram 3.** `URLInputFile` streams the URL through the bot's own HTTP session, with optional `headers` and a `timeout` that defaults to 30 seconds, and fails on an HTTP error status[9]. Files the bot already has go up with `FSInputFile` or `BufferedInputFile`[9]:

```python
from aiogram.types import FSInputFile, URLInputFile

await bot.send_photo(chat_id, URLInputFile(image_url, filename="photo.jpg"))
await bot.send_document(
    chat_id,
    URLInputFile(report_url, headers={"Authorization": f"Bearer {api_token}"}, filename="report.xlsx"),
)
await bot.send_document(chat_id, FSInputFile("/tmp/report.pdf"))
```

**python-telegram-bot.** A string that is not a local file path is sent to Telegram unchanged, as a URL; `bytes` and open files are uploaded[12]. So download the bytes yourself. `httpx` is already a dependency of python-telegram-bot[13]:

```python
import httpx

async with httpx.AsyncClient(timeout=30, follow_redirects=True) as client:
    response = await client.get(image_url)
    response.raise_for_status()

await context.bot.send_photo(chat_id=chat_id, photo=response.content)
```

**grammY.** An `InputFile` built from a `URL` object is fetched by grammY and uploaded; a failed download throws `Download failed, received HTTP status ...` in your code, which tells you the status Telegram never would[15]:

```ts
import { InputFile } from "grammy";

await ctx.replyWithPhoto(new InputFile(new URL(imageUrl)));
```

**Telegraf 4.** `Input.fromURL` only passes the string to Telegram, which downloads it; `Input.fromURLStream` streams the URL through your bot instead[17]:

```ts
import { Input } from "telegraf";

await ctx.replyWithPhoto(Input.fromURLStream(imageUrl, "photo.jpg"));
```

**curl**, for testing with the raw Bot API:

```sh
curl -s "https://api.telegram.org/bot$BOT_TOKEN/sendPhoto" \
  -F "chat_id=$CHAT_ID" \
  -F "photo=@photo.jpg"
```

### Then send by file_id

The `Message` that comes back holds the file's `file_id`. Save it: sending by `file_id` has no size limit and needs no download at all[1]. A `file_id` works only for the bot that received it[1]; if a saved one fails, see [wrong file identifier/HTTP URL specified](https://livops.dev/en/guides/error-telegram-wrong-file-identifier).

### Fall back to an upload only when the URL fails

If most of your links work and you want to keep sending them by URL, catch this family and upload instead. In aiogram:

```python
from aiogram.exceptions import TelegramBadRequest
from aiogram.types import URLInputFile

URL_ERRORS = ("failed to get http url content", "wrong type of the web page content")

try:
    msg = await bot.send_photo(chat_id, image_url)
except TelegramBadRequest as e:
    if not any(text in e.message.lower() for text in URL_ERRORS):
        raise
    msg = await bot.send_photo(chat_id, URLInputFile(image_url))
```

aiogram puts Telegram's description in `e.message`[7][8]. In grammY compare `e.description` of a `GrammyError`[14], in Telegraf `e.description` of a `TelegramError`[16], and in python-telegram-bot `e.message.lower()` of a `BadRequest`[10]. If the upload fails too, the error is then about the file itself, with your own library's message instead of Telegram's.

### Or give Telegram a link it can use

If you want Telegram to fetch the file — a public image on your site, a CDN — make sure the link is one it can download.

## How to check a URL before you send it

Run this from a machine outside your network, not from the bot's own server:

```sh
curl -sS -o /dev/null -w "%{http_code} %{content_type} %{size_download} bytes %{time_total}s\n" "$FILE_URL"
```

What you want to see:

- `200`, with no login: not `302` to a login page, `401`, `403` or `404`;
- the file's own `Content-Type` — `image/jpeg`, `image/png`, `video/mp4`, `application/pdf` — not `text/html`;
- a size within the URL limits: 5 MB for a photo, 20 MB for anything else[1];
- an answer in a second or two, not a long wait.

Then send it once by hand with the same token the bot uses:

```sh
curl -s "https://api.telegram.org/bot$BOT_TOKEN/sendPhoto" \
  --data-urlencode "chat_id=$CHAT_ID" \
  --data-urlencode "photo=$FILE_URL"
```

`"ok":true` means the link is fine, and the bot is sending something else: log the exact URL it passes. The same error means the link is the problem: upload instead.

A Local Bot API Server changes the upload side, not this one: it lets the bot upload files up to 2000 MB, and by a local path with the `file` URI scheme[1]. A URL is still something to be downloaded.

## On Livops

- **Files on the bot's own disk.** A file the bot made — a chart, a PDF report, a resized photo — is already where the bot can upload it: write it to `/tmp`, which is wiped on every restart and deploy and holds 128 MB, or to `/app/data` (its path is in `DATA_DIR`), which is kept across deploys. Upload it from there with `FSInputFile` or its equivalent; do not serve it over HTTP for Telegram.
- **No address to serve it from.** A `bot` service needs no public URL and a `worker` has none, so a link to a file inside them, or to `localhost`, is not one Telegram can open. Databases are reachable only from inside the project, by internal names such as `postgres`.
- **Storage buckets.** A [storage bucket](https://livops.dev/en/docs/storage) is private by default and gives temporary signed links (presigned URLs); generate one right before each send. The whole bucket can be made public instead: a `..._PUBLIC_URL` variable is then added, and URLs are path-style, `https://s3.livops.app/<bucket>/<file>`. Either way, Telegram needs no login, and the URL limits above still apply.
- **The right Content-Type.** When the bot uploads a file to the bucket with `boto3`, pass `ContentType` in `ExtraArgs`[19][20], then check the link with the `curl` line above:

  ```python
  import os, boto3

  s3 = boto3.client("s3", endpoint_url=os.environ["S3_ENDPOINT"])
  s3.upload_file("chart.png", os.environ["S3_BUCKET"], "charts/chart.png", ExtraArgs={"ContentType": "image/png"})
  url = s3.generate_presigned_url(
      "get_object", Params={"Bucket": os.environ["S3_BUCKET"], "Key": "charts/chart.png"}, ExpiresIn=600
  )
  ```

- **Logs.** Log the URL next to each failed send. The project's **Logs** page shows the error line, and `livops logs <service> -f` follows it from the terminal; see [CLI](https://livops.dev/en/docs/cli).

A bot costs **19 credits a month** (19,000 so'm), and one 1 GB storage bucket per team is free; see [Pricing](https://livops.dev/en/docs/pricing) and [Files and data](https://livops.dev/en/docs/files).

## Questions

**Why does the link open in my browser but Telegram cannot get it?**

Your browser is not the one downloading it. With a URL, Telegram's servers fetch the file over the internet, without your cookies, your login, your VPN or your local network. A link to localhost, a private IP address, a page behind a login or a signed link that has expired works for you and fails for them.

**What are the size limits when sending a file by URL?**

5 MB for photos and 20 MB for other types of content. Uploading the file yourself with multipart/form-data allows 10 MB for photos and 50 MB for other files, and resending by file_id has no limit.

**How do I send a file Telegram cannot download?**

Download it in your bot and upload it. aiogram's URLInputFile and grammY's InputFile with a URL object do that in one line, Telegraf has Input.fromURLStream, and in python-telegram-bot you download the bytes, for example with httpx, and pass them as the photo or document.

**What is the difference between failed to get HTTP URL content and wrong type of the web page content?**

In the Bot API server's source the first is Telegram's WEBPAGE_CURL_FAILED, a failure while fetching the URL. The second is WEBPAGE_MEDIA_EMPTY: Telegram fetched something, but it was not media it could send. Both are fixed the same way: a direct public link with the file's own Content-Type, or an upload.

**Can I send a document of any type by URL?**

No. The Bot API says sending by URL in sendDocument currently works only for PDF and ZIP files, the file must have the correct MIME type, and video notes and live photos cannot be sent by URL at all. For other files, upload them.

**Should I retry the same URL?**

Once at most, if the server behind it may have been slow or briefly down. If it fails again, the link itself is the problem: upload the file instead, and save the file_id Telegram returns so the next sends need no URL at all.

## Sources

1. [Telegram Bot API — Making requests, Sending files, sendPhoto, sendVideoNote, Using a Local Bot API Server](https://core.telegram.org/bots/api). Checked 3 December 2026.
2. [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 3 December 2026.
3. [Telegram API — messages.sendMedia (possible errors)](https://core.telegram.org/method/messages.sendMedia). Checked 3 December 2026.
4. [TDLib source — td/telegram/Photo.cpp](https://raw.githubusercontent.com/tdlib/td/master/td/telegram/Photo.cpp). Checked 3 December 2026.
5. [TDLib source — td/telegram/files/FileManager.cpp](https://raw.githubusercontent.com/tdlib/td/master/td/telegram/files/FileManager.cpp). Checked 3 December 2026.
6. [TDLib source — td/telegram/MessageQueryManager.cpp](https://raw.githubusercontent.com/tdlib/td/master/td/telegram/MessageQueryManager.cpp). Checked 3 December 2026.
7. [aiogram source — aiogram/exceptions.py](https://raw.githubusercontent.com/aiogram/aiogram/dev-3.x/aiogram/exceptions.py). Checked 3 December 2026.
8. [aiogram source — aiogram/client/session/base.py](https://raw.githubusercontent.com/aiogram/aiogram/dev-3.x/aiogram/client/session/base.py). Checked 3 December 2026.
9. [aiogram source — aiogram/types/input_file.py](https://raw.githubusercontent.com/aiogram/aiogram/dev-3.x/aiogram/types/input_file.py). Checked 3 December 2026.
10. [python-telegram-bot source — telegram/error.py](https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/src/telegram/error.py). Checked 3 December 2026.
11. [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 3 December 2026.
12. [python-telegram-bot source — telegram/_utils/files.py](https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/src/telegram/_utils/files.py). Checked 3 December 2026.
13. [PyPI — python-telegram-bot](https://pypi.org/project/python-telegram-bot/). Checked 3 December 2026.
14. [grammY source — src/core/error.ts](https://raw.githubusercontent.com/grammyjs/grammY/main/src/core/error.ts). Checked 3 December 2026.
15. [grammY source — src/types.node.ts](https://raw.githubusercontent.com/grammyjs/grammY/main/src/types.node.ts). Checked 3 December 2026.
16. [Telegraf source — src/core/network/error.ts](https://raw.githubusercontent.com/telegraf/telegraf/v4/src/core/network/error.ts). Checked 3 December 2026.
17. [Telegraf 4.16.3 source — src/input.ts](https://github.com/telegraf/telegraf/blob/v4.16.3/src/input.ts). Checked 3 December 2026.
18. [Boto3 docs — Presigned URLs](https://docs.aws.amazon.com/boto3/latest/guide/s3-presigned-urls.html). Checked 3 December 2026.
19. [Boto3 docs — Uploading files (ExtraArgs)](https://docs.aws.amazon.com/boto3/latest/guide/s3-uploading-files.html). Checked 3 December 2026.
20. [s3transfer source — s3transfer/manager.py (ALLOWED_UPLOAD_ARGS)](https://raw.githubusercontent.com/boto/s3transfer/develop/s3transfer/manager.py). Checked 3 December 2026.
