Introducing Livops 2.0! Promo codeCEOgives you 8,000 so‘m on your balance.What’s new

Telegram 429: Too Many Requests: retry after N — how to fix it

Telegram's flood control is telling your bot to slow down: wait the number of seconds in retry_after, then send the same request again. It comes from sending too fast — more than about one message a second to one chat, 20 a minute to a group, or about 30 a second in a broadcast. Wait and retry in code, and send broadcasts from one queue at a steady pace.

By Livops team, the people who build and run LivopsUpdated

The message, as Telegram returns it with error code 429:

Too Many Requests: retry after 35

Each library wraps it in its own words; the number is the one to read.

Library What you see
aiogram 3 TelegramRetryAfter: Telegram server says - Flood control exceeded on method 'SendMessage' in chat 123456. Retry in 35 seconds.[4]
python-telegram-bot telegram.error.RetryAfter: Flood control exceeded. Retry in 35 seconds[5]
grammY GrammyError: Call to 'sendMessage' failed! (429: Too Many Requests: retry after 35)[11]
Telegraf TelegramError: 429: Too Many Requests: retry after 35[10]

This page explains what Telegram’s flood control is and which limits it documents, lists the usual causes, shows the retry in each of the four libraries from their own documentation, and ends with how to run a broadcast queue — on any host, and on Livops.

What does the error mean?

Every Bot API response says whether it succeeded. A failed one carries an error_code, a description, and sometimes parameters of type ResponseParameters, which can help to handle the error automatically[2]. For a 429, parameters.retry_after is the number of seconds left to wait before the request can be repeated[2].

Nothing is broken and nothing was sent. The fix is to wait retry_after seconds and send the same request again; grammY’s guide calls this the only correct way to handle it, and notes that a 429 can happen at any time[7].

The limits, as Telegram documents them

Telegram’s Bots FAQ gives three numbers[1]:

  • One chat: avoid sending more than one message per second. Short bursts over this may be allowed, but eventually you get 429 errors.
  • One group: a bot cannot send more than 20 messages per minute.
  • Bulk notifications: a bot cannot broadcast more than about 30 messages per second, unless it enables paid broadcasts.

For bigger audiences, Telegram suggests spreading a broadcast over longer intervals, for example 8–12 hours[1]. Paid broadcasts, enabled in @BotFather, allow up to 1000 messages per second; each message over the free 30 a second costs 0.1 Telegram Stars from the bot’s balance, and only successfully sent messages are charged. To enable them, a bot needs at least 100,000 Stars and at least 100,000 monthly active users[1]. Each send then passes allow_paid_broadcast[2].

Treat the numbers as guidance, not a contract. grammY’s documentation stresses that the real limits are unspecified and depend on payloads, user counts and other factors; that the 30-a-second figure is about messages the bot starts, not replies to users; and that hitting rate limits does not get a bot banned — ignoring them does[7].

Causes, most common first

1. A broadcast loop that never waits

for user_id in users:
    await bot.send_message(user_id, text)  # thousands in a row

The first few dozen go through, then every send fails with 429. If the loop catches the error and moves on, those users simply never get the message.

2. Too many messages to one chat

A bot that posts every log line to a channel, edits a progress message several times a second, or answers a command with ten messages in a row. One chat tolerates about one message a second, a group 20 a minute[1]. grammY also mentions an unofficial figure of about 20 message edits a minute per group[7].

3. Sending everything in parallel

asyncio.gather or Promise.all over the whole user list. grammY advises against sending many messages in parallel and suggests around three concurrent sends at most[7].

4. Retrying straight away

A retry that does not wait — or a process that crashes on the 429, restarts and starts the broadcast again from the top — turns one 429 into a stream of them, and sends duplicates to the users at the start of the list.

How to handle retry_after in each library

aiogram 3

aiogram raises TelegramRetryAfter, with the wait in retry_after[3][4]. Catch it, sleep, and send the same message again:

import asyncio

from aiogram import Bot
from aiogram.exceptions import TelegramForbiddenError, TelegramRetryAfter


async def send(bot: Bot, chat_id: int, text: str) -> bool:
    while True:
        try:
            await bot.send_message(chat_id, text)
            return True
        except TelegramRetryAfter as e:
            await asyncio.sleep(e.retry_after)
        except TelegramForbiddenError:
            return False  # the bot may not write here: skip this chat

TelegramForbiddenError is aiogram’s error for a bot that was kicked from the chat[3]; in a broadcast, skip that chat rather than retry it.

python-telegram-bot

The error is telegram.error.RetryAfter. Since v22.2, retry_after may be an int or a datetime.timedelta, and in a future major version it will be a timedelta[5], so handle both:

import asyncio
import datetime as dtm

from telegram.error import RetryAfter


async def send(bot, chat_id: int, text: str) -> None:
    while True:
        try:
            await bot.send_message(chat_id, text)
            return
        except RetryAfter as e:
            delay = e.retry_after
            if isinstance(delay, dtm.timedelta):
                delay = delay.total_seconds()
            await asyncio.sleep(delay)

python-telegram-bot also ships a rate limiter. AIORateLimiter needs pip install "python-telegram-bot[rate-limiter]"; by default it allows 30 requests a second overall and 20 a minute per group, and retries a RetryAfter 0 times unless you set max_retries[6]. A RetryAfter pauses all of the bot’s requests for retry_after plus 0.1 seconds[6]:

import os

from telegram.ext import AIORateLimiter, ApplicationBuilder

app = (
    ApplicationBuilder()
    .token(os.environ["BOT_TOKEN"])
    .rate_limiter(AIORateLimiter(max_retries=3))
    .build()
)

grammY

Install the auto-retry plugin and every API call waits and retries on 429 by itself[8]:

import { autoRetry } from "@grammyjs/auto-retry";

bot.api.config.use(autoRetry());

By default it retries without limit and waits however long Telegram asks[9]. maxRetryAttempts caps the retries, and maxDelaySeconds makes a request fail at once when retry_after is longer than that[8] — useful in a handler, where an answer half a minute late is worse than none.

Telegraf

Telegraf throws a TelegramError whose code is the error code and whose parameters are Telegram’s ResponseParameters[10]:

const { TelegramError } = require('telegraf');

async function send(telegram, chatId, text) {
  for (;;) {
    try {
      return await telegram.sendMessage(chatId, text);
    } catch (err) {
      const wait = err instanceof TelegramError && err.code === 429
        ? err.parameters?.retry_after
        : undefined;
      if (!wait) throw err;
      await new Promise((resolve) => setTimeout(resolve, wait * 1000));
    }
  }
}

A broadcast queue that does not hit 429

The pattern every library’s advice adds up to: send, wait and retry on 429, repeat — no artificial delays, no ignored 429s, little or no parallelism[7].

  1. Keep the audience in a database. To message every user, the bot has to have stored their chat ids[7].
  2. Write the broadcast as rows, not as a loop in memory. One row per recipient with a sent_at column. The sender marks each row as it goes, so a restart continues where it stopped instead of starting again.
  3. Send from one process. One sender that works through the rows in order, using the retry above, instead of several copies racing each other into the same limit.
  4. Pace it for its size. At about 30 a second, 100,000 users take close to an hour; Telegram suggests spreading big broadcasts over hours[1].
  5. Skip, do not retry, chats that refuse. A chat the bot may no longer write to raises a different error — aiogram’s TelegramForbiddenError[3], python-telegram-bot’s Forbidden[5] — not a 429. Mark the row and move on.

On Livops

Livops does not slow your bot’s requests down or retry them for you: the limits are Telegram’s, and the retry is in your code. What Livops gives you is a place to run the queue properly:

  • The sender as a worker. Add a worker service to the bot’s project: an always-on background process with no public URL. Its livops.json:

    {
      "kind": "worker",
      "start": ".venv/bin/python sender.py"
    }
  • The same token, without copying it. A worker’s variable can take its value from another service’s variable by reference, so the token stays in one place — see Variables. The worker only sends; it must never call getUpdates, or it conflicts with the bot — see Conflict: terminated by other getUpdates request.

  • The queue in a database. Add PostgreSQL or Redis to the project under Databases, and DATABASE_URL or REDIS_URL is written into every service in the environment, the bot and the worker alike.

  • A broadcast at a fixed time. A cron service can put tomorrow’s rows into the queue on a schedule, which is read in UTC: 0 4 * * * is 09:00 in Tashkent. Let the cron job only enqueue and the worker send, so a long broadcast never depends on one scheduled run. The syntax is in Cron and workers.

  • Logs. Print the retry_after values you get; the project’s Logs page shows them, and get_logs over MCP returns up to 5000 lines.

A worker or a cron service costs what a bot costs, 19 credits a month (19,000 so’m). One credit is 1,000 so’m; see Pricing.

Questions

How long do I have to wait after a 429?

Exactly as long as retry_after says, in seconds, and then send the same request again. The number is in the error's parameters; every major library exposes it. Retrying sooner only earns another 429.

What are Telegram's rate limits for bots?

Telegram documents three: avoid more than one message a second in a single chat, no more than 20 messages a minute in a group, and about 30 messages a second for bulk notifications. Short bursts over the per-chat limit may pass, but the exact limits are not published and vary.

Will my bot be banned for hitting 429?

Hitting the limit is not what gets a bot into trouble; ignoring it is. A 429 is Telegram's way of asking you to wait. Wait the retry_after seconds every time and keep sending.

How do I send a message to all my users without 429?

From one queue, one message at a time or with very little concurrency, waiting on every 429. Store the chat ids in a database, record who has been sent the message so a restart does not send it twice, and spread a large broadcast over hours. Paid broadcasts raise the ceiling for very large bots.

Can I pay Telegram for higher limits?

Yes, with paid broadcasts: up to 1000 messages a second, at 0.1 Telegram Stars for each message over the free 30 a second. The bot needs at least 100,000 Stars on its balance and at least 100,000 monthly active users, and you pass allow_paid_broadcast on each send.

Can I run the broadcast queue next to my bot on Livops?

Yes, as a worker service in the same project: always on, no public URL, and the same databases' variables. It must only send, never call getUpdates, or it conflicts with the bot. A worker costs what a bot costs, 19 credits a month (19,000 so'm).

Sources

  1. Telegram — Bots FAQ (limits, broadcasting) (core.telegram.org). Checked .
  2. Telegram Bot API — Making requests, ResponseParameters, sendMessage (core.telegram.org). Checked .
  3. aiogram — Errors (docs.aiogram.dev). Checked .
  4. aiogram source — aiogram/exceptions.py (raw.githubusercontent.com). Checked .
  5. python-telegram-bot — telegram.error (docs.python-telegram-bot.org). Checked .
  6. python-telegram-bot — AIORateLimiter (docs.python-telegram-bot.org). Checked .
  7. grammY — Scaling up IV, flood limits (grammy.dev). Checked .
  8. grammY — Retry API requests (auto-retry) (grammy.dev). Checked .
  9. grammY auto-retry source — src/mod.ts (raw.githubusercontent.com). Checked .
  10. Telegraf source — src/core/network/error.ts (raw.githubusercontent.com). Checked .
  11. grammY source — src/core/error.ts (raw.githubusercontent.com). Checked .

Put your project online today

Connect GitHub or drop a folder. No card is asked for.

Deploy your bot

Got a question? — @livops_uz