# TelegramNetworkError: HTTP Client says - ClientConnectorError (aiogram): how to fix it

> aiogram.exceptions.TelegramNetworkError: HTTP Client says - ClientConnectorError: Cannot connect to host api.telegram.org:443 means the bot could not open a connection to Telegram's Bot API at all: the code and the token are not the problem, the network is. The usual causes are a network that blocks Telegram, DNS, a missing or broken proxy, a bad IPv6 route, a server with no outbound access, or a slow path that ends in timeouts. Test the same path with curl, then fix the network, set aiogram's proxy, or run the bot where api.telegram.org is reachable.

Source: https://livops.dev/en/guides/error-aiogram-telegram-network-error

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

The bot stops at start, or its log fills with lines like these:

```text
aiogram.exceptions.TelegramNetworkError: HTTP Client says - ClientConnectorError: Cannot connect to host api.telegram.org:443 ssl:default [Connect call failed ('149.154.166.110', 443)]
```

```text
Failed to fetch updates - TelegramNetworkError: HTTP Client says - ClientConnectorError: Cannot connect to host api.telegram.org:443 ssl:default [...]
Sleep for 1.000000 seconds and try again... (tryings = 0, bot id = 123456789)
```

The bot cannot reach `api.telegram.org`. This page explains what aiogram's message says, shows how to test the same connection with curl, lists the causes from the most common, and covers aiogram's proxy and session settings. It ends with why moving the bot to a network that reaches Telegram fixes it without a line of code.

## What does the error mean?

Every Bot API call is an HTTPS request to `https://api.telegram.org/bot<token>/METHOD_NAME`[1]. aiogram sends it with aiohttp. When aiohttp raises a client error, aiogram catches it and raises `TelegramNetworkError` instead, with the error's class name and text as the message[2]; the exception's label is `HTTP Client says`[3]. A timeout becomes `Request timeout error` instead[2]. aiogram removes the bot token from the message and keeps the original aiohttp error on the exception's `original` attribute[2][3].

`ClientConnectorError` is aiohttp's error for a connection that could not be established[7]. Its text is `Cannot connect to host <host>:<port> ssl:<ssl> [<reason>]`[7], and the reason in brackets comes from the operating system. `Connect call failed ('<address>', 443)` is what Python's asyncio reports when the TCP connection to that address fails[9]. So nothing was sent: the token, the handlers and the Bot API are not involved yet. The problem is the path from your machine to Telegram.

### Where it shows up

- **At start, it ends the process.** `start_polling` first calls `getMe` to learn the bot's name, outside the retry loop[5]. If Telegram is unreachable then, the exception goes up through `start_polling` and the bot exits. `getMe` is the Bot API's method for testing a token[1], so it is usually the first call to fail.
- **While polling, it is retried.** A failed `getUpdates` is logged as `Failed to fetch updates - ...`, followed by `Sleep for ... seconds and try again...`; the delay grows from 1 to 5 seconds, and `Connection established` is logged when a request works again[5]. A few such lines during a network hiccup are harmless. A steady stream means the bot cannot reach Telegram.
- **In a handler**, `await message.answer(...)` raises it like any other exception.

### The class name says which step failed

aiogram prints the exact aiohttp class[2], and aiohttp has a subclass per step[8][7]:

| In the message | What failed |
| --- | --- |
| `ClientConnectorDNSError` | Resolving `api.telegram.org` to an address |
| `ClientConnectorError` | Opening the TCP connection: refused, unreachable, or no answer |
| `ClientProxyConnectionError` | Connecting to the proxy |
| `ClientConnectorSSLError`, `ClientConnectorCertificateError` | The TLS handshake or the certificate check |
| `Request timeout error` | The connection worked, but the answer did not come in time; see [Timed out](https://livops.dev/en/guides/error-telegram-timed-out) |

## Test the connection with curl

Run this on the machine where the bot runs, in the same container if it runs in one:

```sh
curl -sS -o /dev/null --noproxy '*' --connect-timeout 10 \
  -w 'dns %{time_namelookup}s  tcp %{time_connect}s  tls %{time_appconnect}s  http %{http_code}\n' \
  "https://api.telegram.org/bot$BOT_TOKEN/getMe"
```

`--connect-timeout` limits only the connection phase[10]. The `-w` variables are the seconds until name resolving finished, until the TCP connection was made, and until the TLS handshake finished, plus the HTTP code[10]. `--noproxy '*'` disables any proxy curl would take from the environment[10], which matches aiogram: aiohttp reads proxy settings from the environment only when `trust_env` is on, and it is off by default[8]; aiogram creates its session without it[2].

What the result tells you:

- **`Could not resolve host`**: DNS. See cause 2.
- **No connection within 10 seconds, or `Connection refused`**: the network or a firewall drops the traffic. See causes 1 and 5.
- **`http 200`**: this machine reaches Telegram. If the bot still fails, it runs somewhere else (another container, another host), or through a proxy curl did not use.
- **`http 401`**: the network works, the token does not. See [401 Unauthorized](https://livops.dev/en/guides/error-telegram-401-unauthorized).

Then compare the address families. `-4` makes curl request only IPv4 addresses, `-6` only IPv6[10]:

```sh
curl -4 -sS -o /dev/null -w '%{http_code}\n' --connect-timeout 10 "https://api.telegram.org/bot$BOT_TOKEN/getMe"
curl -6 -sS -o /dev/null -w '%{http_code}\n' --connect-timeout 10 "https://api.telegram.org/bot$BOT_TOKEN/getMe"
```

And if you have a proxy, test it on its own with `-x`, which takes `http://`, `socks4://`, `socks5://` and `socks5h://` proxies[10]:

```sh
curl -sS -o /dev/null -w '%{http_code}\n' -x socks5h://user:password@proxy.example:1080 "https://api.telegram.org/bot$BOT_TOKEN/getMe"
```

Keep the token out of anything you paste into a chat or an issue.

## Causes, most common first

### 1. The network blocks Telegram

A firewall, the hosting provider or the network operator drops connections to Telegram's addresses. curl hangs at `tcp` and then gives up; aiogram shows `ClientConnectorError` with a connect failure, or a timeout. Nothing in the code fixes this: run the bot on a network that reaches Telegram, or send its traffic through a proxy that does (cause 3).

### 2. DNS does not resolve api.telegram.org

The message names `ClientConnectorDNSError`[8], and curl says it could not resolve the host. The machine's resolver is down, wrong, or filters the name. Fix the resolver the system uses, then restart the bot: aiogram's connector caches DNS answers for an hour (`ttl_dns_cache=3600`)[2], so a running bot can keep a stale answer after you fix DNS.

### 3. A proxy is needed but not used, or is broken

On a network that only reaches the internet through a proxy, the usual trap is the environment: `HTTPS_PROXY` is set, curl and pip use it, and aiogram ignores it, because aiohttp reads proxy variables only with `trust_env` on[8] and aiogram does not turn it on[2]. Pass the proxy to aiogram explicitly; see the settings below.

When the proxy itself fails, the error is about the proxy, not Telegram: test it with `curl -x` as above.

### 4. A broken IPv6 route

If `api.telegram.org` resolves to IPv6 addresses on your server, and the server has IPv6 configured but its route does not work, connections to those addresses fail. By default aiohttp accepts both families[8] and uses Happy Eyeballs, starting the next connection attempt after 0.25 seconds[8], so a dead IPv6 route usually costs a moment rather than the connection. If `curl -6` fails, `curl -4` works and the bot still fails, fix IPv6 on the server or force IPv4 in aiogram, below.

### 5. The server has no outbound access

Some machines are not allowed to open connections to the internet at all: a private network without a NAT gateway, a container network with egress rules, a firewall that allows only listed hosts. Inbound traffic may work, so a website on the same machine answers, while every outbound request fails. curl from the machine fails the same way. Open outbound HTTPS to `api.telegram.org`, or run the bot elsewhere.

### 6. A slow path ends in timeouts

When the connection opens but is slow, the error reads `HTTP Client says - Request timeout error` instead[2]. aiogram's session allows 60 seconds per request by default[4]. For long polling it waits the session timeout plus the polling timeout[5]. Timeouts, and when to raise them, are covered in [Timed out](https://livops.dev/en/guides/error-telegram-timed-out).

## aiogram's proxy and session settings

All of these go on `AiohttpSession`, which aiogram uses by default[6], passed to the `Bot`:

```python
import os

from aiogram import Bot
from aiogram.client.session.aiohttp import AiohttpSession

session = AiohttpSession(
    proxy=os.environ.get("TELEGRAM_PROXY"),  # e.g. socks5://user:password@host:1080, or unset
    timeout=90,                              # seconds per request; the default is 60
)
bot = Bot(token=os.environ["BOT_TOKEN"], session=session)
```

- **The proxy needs `aiohttp-socks`.** Without it, `AiohttpSession(proxy=...)` raises `RuntimeError` asking you to install it[2][6]. Add `aiohttp-socks` to `requirements.txt`.
- **Supported proxies** are `http` (tunnelling), `socks4(a)` and `socks5`[6]. Credentials go in the URL, or as an `aiohttp.BasicAuth` in a `(url, auth)` tuple; an iterable of proxies makes a chain[6].
- **DNS goes through the proxy.** aiogram asks the proxy to resolve names (`rdns=True`)[2], so a broken local resolver does not matter once a proxy is set.
- **`timeout`** is the session's request timeout[4]. Raising it helps a slow path; it does nothing for a connection that cannot open.
- **Retries while polling** follow `backoff_config`, a `BackoffConfig` with `min_delay=1.0, max_delay=5.0, factor=1.3, jitter=0.1` by default; pass your own to `start_polling`[5].

### Wait for Telegram at start instead of exiting

Since the first `getMe` is not retried[5], a bot that starts while the network is down exits. If you would rather have it wait:

```python
import asyncio
import logging
import os

from aiogram import Bot, Dispatcher
from aiogram.exceptions import TelegramNetworkError

dp = Dispatcher()


async def wait_for_telegram(bot: Bot) -> None:
    delay = 1
    while True:
        try:
            await bot.get_me()
            return
        except TelegramNetworkError as e:
            logging.warning("Telegram unreachable (%s), retrying in %s s", e, delay)
            await asyncio.sleep(delay)
            delay = min(delay * 2, 60)


async def main() -> None:
    bot = Bot(token=os.environ["BOT_TOKEN"])
    await wait_for_telegram(bot)
    await dp.start_polling(bot)


if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
    asyncio.run(main())
```

This rides out a short outage. It does not fix a network that never reaches Telegram; the warning in the log keeps saying so.

### Force IPv4, as a last resort

`AiohttpSession` takes no address-family argument: it builds aiohttp's `TCPConnector` from its own internal settings[2]. aiohttp's connector takes `family=socket.AF_INET` for IPv4 only[8], and that setting can be added before the first request:

```python
import socket

session = AiohttpSession()
session._connector_init["family"] = socket.AF_INET  # private attribute: re-check after upgrading aiogram
```

`_connector_init` is internal to aiogram and can change in any release. Fixing the server's IPv6 route is the better fix.

## Why running the bot where Telegram is reachable fixes it

`ClientConnectorError` is a property of the network the bot runs in, not of the bot. The same code, on a machine where the curl check above returns `http 200`, connects. That is why the error often appears after a move: from a laptop to a server, from one provider or country to another, or into a container network with stricter rules.

A webhook does not get around it. With a webhook Telegram delivers updates to you, and you can answer one update with one method in the webhook's reply, but you cannot see whether that request succeeded[1]. Everything else the bot does, sending messages and files included, is still a request to `api.telegram.org`. The bot needs outbound access to Telegram either way.

The move does not cost the messages sent meanwhile, within limits: Telegram keeps incoming updates on its server until the bot receives them, but not longer than 24 hours[1].

## On Livops

- **Test before you move.** The deciding check is the curl test above, run from where the bot will run. Livops's servers are in Uzbekistan. A bot runs there around the clock, and both polling and webhooks work. If you choose a webhook, Livops gives Telegram the address itself.
- **Where you see it.** A bot that exits on this error at start fails its deploy as `start_failed`, and the traceback is on the project's **Logs** page. A bot's previous version is stopped before the new one starts, because two copies polling Telegram would conflict, so the bot is down until a deploy succeeds.
- **Settings as variables.** Put `BOT_TOKEN`, and `TELEGRAM_PROXY` if you use one, under **Settings → Variables**, mark the token as a **secret**, and read them as in the code above. New values take effect on the next deploy; restart the service to apply them now.
- **The start command.** For an aiogram bot, write `.venv/bin/python bot.py` in **Settings → Start**, or a `Procfile` with `worker: .venv/bin/python bot.py`.

A bot costs **19 credits a month** (19,000 so'm). Hosting an aiogram bot, step by step: [aiogram bot hosting](https://livops.dev/en/guides/aiogram-bot-hosting). Startup failures in the docs: [The app did not start](https://livops.dev/en/docs/error-start). If the bot connects but runs twice, see [Conflict: terminated by other getUpdates request](https://livops.dev/en/guides/error-telegram-conflict-getupdates).

## Questions

**What does TelegramNetworkError HTTP Client says ClientConnectorError mean?**

aiogram tried to open a connection to api.telegram.org on port 443 and could not. aiohttp raised ClientConnectorError, and aiogram wrapped it in TelegramNetworkError with the label HTTP Client says. The request never reached Telegram, so the token and the handlers are not the cause; the network between the bot and Telegram is.

**Why does the bot crash at start but only log errors later?**

start_polling first calls getMe to learn the bot's name, and that call is not retried, so a network error there ends the process. Once polling runs, a failed getUpdates is logged as Failed to fetch updates and retried with a delay that grows from 1 to 5 seconds.

**curl reaches api.telegram.org but the bot does not. Why?**

Most often curl uses a proxy from the HTTPS_PROXY or ALL_PROXY environment variables and aiogram does not: aiohttp ignores those variables unless trust_env is on, and aiogram does not turn it on. Run curl with --noproxy '*' to test the path aiogram takes, and pass the proxy to AiohttpSession explicitly.

**How do I use a proxy with aiogram 3?**

Install aiohttp-socks and create the bot with Bot(token, session=AiohttpSession(proxy='socks5://user:password@host:1080')). aiogram supports http tunnelling, socks4, socks4a and socks5 proxies, credentials in the URL or as aiohttp.BasicAuth, and proxy chains.

**Is it a timeout or a connection error?**

Read the text after HTTP Client says. ClientConnectorError, or one of its subclasses such as ClientConnectorDNSError, means no connection was opened. Request timeout error means the request did not finish within the session's limit, 60 seconds by default; that case has its own guide.

**Will a webhook instead of polling fix it?**

No. With a webhook Telegram connects to your bot to deliver updates, but sending messages, files and every other method is still a request from the bot to api.telegram.org. The bot needs outbound access to Telegram either way.

**Do I lose messages while the bot cannot reach Telegram?**

Not right away. Telegram keeps incoming updates on its server until the bot receives them, but not longer than 24 hours. Restore the connection within that window and the bot gets the queued updates.

## Sources

1. [Telegram Bot API — Making requests, Getting updates, getMe](https://core.telegram.org/bots/api). Checked 3 December 2026.
2. [aiogram source — aiogram/client/session/aiohttp.py (v3.34.0)](https://raw.githubusercontent.com/aiogram/aiogram/v3.34.0/aiogram/client/session/aiohttp.py). Checked 3 December 2026.
3. [aiogram source — aiogram/exceptions.py (v3.34.0)](https://raw.githubusercontent.com/aiogram/aiogram/v3.34.0/aiogram/exceptions.py). Checked 3 December 2026.
4. [aiogram source — aiogram/client/session/base.py (v3.34.0)](https://raw.githubusercontent.com/aiogram/aiogram/v3.34.0/aiogram/client/session/base.py). Checked 3 December 2026.
5. [aiogram source — aiogram/dispatcher/dispatcher.py (v3.34.0)](https://raw.githubusercontent.com/aiogram/aiogram/v3.34.0/aiogram/dispatcher/dispatcher.py). Checked 3 December 2026.
6. [aiogram documentation — Aiohttp session](https://docs.aiogram.dev/en/latest/api/session/aiohttp.html). Checked 3 December 2026.
7. [aiohttp source — aiohttp/client_exceptions.py (v3.14.5)](https://raw.githubusercontent.com/aio-libs/aiohttp/v3.14.5/aiohttp/client_exceptions.py). Checked 3 December 2026.
8. [aiohttp docs — Client reference (ClientSession, TCPConnector, exceptions)](https://docs.aiohttp.org/en/stable/client_reference.html). Checked 3 December 2026.
9. [CPython source — Lib/asyncio/selector_events.py (3.13)](https://raw.githubusercontent.com/python/cpython/3.13/Lib/asyncio/selector_events.py). Checked 3 December 2026.
10. [curl — man page](https://curl.se/docs/manpage.html). Checked 3 December 2026.
