Telegram 403: Forbidden: bot was kicked from the group chat — how to handle it
Someone removed the bot from that group, supergroup or channel, and Telegram refuses every message it sends there. Nothing is broken and a retry will not help: mark the chat inactive in your database, skip it in broadcasts, and mark it active again when the bot is added back. The my_chat_member update tells you the moment it happens.
By Livops team, the people who build and run LivopsUpdated
The full error, as the Telegram Bot API returns it with error code 403[2]:
Forbidden: bot was kicked from the group chat
The same server has two siblings for the other chat types, also 403[2]:
Forbidden: bot was kicked from the supergroup chat
Forbidden: bot was kicked from the channel chat
Your library wraps it in its own words:
| Library | What you see |
|---|---|
| aiogram 3 | TelegramForbiddenError: Telegram server says - Forbidden: bot was kicked from the group chat[4][5] |
| python-telegram-bot | telegram.error.Forbidden: Forbidden: bot was kicked from the group chat[8][9] |
This page explains what the error means, how it differs from the errors that look like it, how to learn about the removal before you send anything, and how a broadcast loop should catch it per chat and keep going. The code is aiogram 3, with the python-telegram-bot equivalent at the end.
What does the error mean?
The bot is no longer in that chat. Before it sends anything, the Bot API server checks the bot’s own status in the target chat. In a basic group where the bot was kicked, it answers bot was kicked from the group chat; in a supergroup or channel where the bot’s status is banned, it answers bot was kicked from the supergroup chat or bot was kicked from the channel chat[2].
So this is not a bug in your code, not a token problem and not a rate limit. An administrator removed the bot. Every later message to that chat gets the same answer until somebody adds the bot back.
The relatives, all 403 and all meaning “stop sending here”[2]:
| Description | What happened |
|---|---|
Forbidden: bot was kicked from the group chat |
Removed from a basic group |
Forbidden: bot was kicked from the supergroup chat |
Removed and banned in a supergroup |
Forbidden: bot was kicked from the channel chat |
Removed and banned in a channel |
Forbidden: bot is not a member of the group chat (or supergroup chat, channel chat) |
The bot is not a member there, for example after it left |
Forbidden: the group chat was deleted |
The basic group no longer exists |
Telegram says the numeric error_code may change in the future[1], so decide on the HTTP status your library already mapped (403) together with the description, not on the number alone.
How is it different from blocked by the user and chat not found?
Three errors show up in the same broadcast logs and need different handling:
| Error | Code | Where | Meaning | What to do |
|---|---|---|---|---|
Forbidden: bot was kicked from the group chat |
403 | Group, supergroup, channel | An admin removed the bot | Mark the chat inactive until the bot is added back |
Forbidden: bot was blocked by the user |
403 | Private chat | The user blocked the bot | Mark the user inactive until they unblock it |
Bad Request: chat not found |
400 | Any | The bot does not know this chat at all | Fix the chat_id or the token |
The first two are about a chat that exists and has shut the bot out; Telegram answers 403 for both[2]. The blocked case has its own page: Forbidden: bot was blocked by the user. The third is a 400: the id is wrong, or this bot has never been in that chat, and the fix is in your data, not in a flag — see Bad Request: chat not found. A basic group that became a supergroup returns another 400 with the new id in it: group chat was upgraded to a supergroup chat.
Learn about it before you send: my_chat_member
You do not have to wait for a failed send. Telegram sends the bot a my_chat_member update whenever the bot’s own status in a chat changes[1]. The update is a ChatMemberUpdated with old_chat_member and new_chat_member; when the bot is removed, the new status is kicked (the member was banned and cannot return or see messages) or left (not a member now, but may join again)[1]. When someone adds the bot back, another my_chat_member arrives with a member or administrator status.
Two details make this work:
- Receive the update.
my_chat_memberis in the default set: an emptyallowed_updateslist means every type exceptchat_member,message_reactionandmessage_reaction_count. If your bot passes its own list togetUpdatesorsetWebhook, put"my_chat_member"in it. A list you set once stays in force: when the parameter is not specified, the previous setting is used[1]. In aiogram 3,start_pollingbuilds the list from the handlers you registered when you do not pass one[7], so amy_chat_memberhandler is enough with polling; with a webhook, passdp.resolve_used_update_types()toset_webhook. - Do not rely on it alone. Telegram keeps undelivered updates for at most 24 hours[1]. A bot that was down longer than that can miss the removal, and chats the bot joined before you added tracking are not in your table yet. Catch the 403 on send as well.
In aiogram, ChatMemberUpdatedFilter(IS_MEMBER >> IS_NOT_MEMBER) matches the transition from member to not-member, and IS_NOT_MEMBER covers both LEFT and KICKED[6].
A complete aiogram 3 bot
One file. It records every group, supergroup and channel the bot is added to, marks it inactive when the bot is removed, and gives the admin a /broadcast command that skips inactive chats and survives a 403 in the middle of the list. The token comes from BOT_TOKEN, the admin’s numeric user id from ADMIN_ID.
import asyncio
import logging
import os
import sqlite3
from aiogram import Bot, Dispatcher, F, Router
from aiogram.exceptions import TelegramAPIError, TelegramForbiddenError, TelegramRetryAfter
from aiogram.filters import IS_MEMBER, IS_NOT_MEMBER, ChatMemberUpdatedFilter, Command, CommandObject
from aiogram.types import ChatMemberUpdated, Message
db = sqlite3.connect(os.path.join(os.environ.get("DATA_DIR", "."), "chats.db"))
db.execute("CREATE TABLE IF NOT EXISTS chats (chat_id INTEGER PRIMARY KEY, active INTEGER NOT NULL)")
def set_active(chat_id: int, active: bool) -> None:
db.execute(
"INSERT INTO chats (chat_id, active) VALUES (?, ?) "
"ON CONFLICT(chat_id) DO UPDATE SET active = excluded.active",
(chat_id, int(active)),
)
db.commit()
router = Router()
not_private = F.chat.type.in_({"group", "supergroup", "channel"})
@router.my_chat_member(not_private, ChatMemberUpdatedFilter(IS_NOT_MEMBER >> IS_MEMBER))
async def on_added(event: ChatMemberUpdated) -> None:
set_active(event.chat.id, True)
@router.my_chat_member(not_private, ChatMemberUpdatedFilter(IS_MEMBER >> IS_NOT_MEMBER))
async def on_removed(event: ChatMemberUpdated) -> None:
logging.info("removed from %s, status %s", event.chat.id, event.new_chat_member.status)
set_active(event.chat.id, False)
async def send_one(bot: Bot, chat_id: int, text: str) -> None:
while True:
try:
await bot.send_message(chat_id, text)
return
except TelegramRetryAfter as e: # 429: wait as asked, then send again
await asyncio.sleep(e.retry_after)
async def broadcast(bot: Bot, text: str) -> tuple[int, int]:
chat_ids = [row[0] for row in db.execute("SELECT chat_id FROM chats WHERE active = 1")]
sent = skipped = 0
for chat_id in chat_ids:
try:
await send_one(bot, chat_id, text)
sent += 1
except TelegramForbiddenError as e: # 403: kicked, not a member, blocked
logging.warning("skip %s: %s", chat_id, e.message)
set_active(chat_id, False)
skipped += 1
except TelegramAPIError as e: # anything else: log it and go on
logging.error("failed %s: %s", chat_id, e.message)
skipped += 1
await asyncio.sleep(0.1)
return sent, skipped
@router.message(Command("broadcast"), F.from_user.id == int(os.environ["ADMIN_ID"]))
async def on_broadcast(message: Message, command: CommandObject, bot: Bot) -> None:
if not command.args:
await message.answer("Usage: /broadcast <text>")
return
sent, skipped = await broadcast(bot, command.args)
await message.answer(f"Sent {sent}, skipped {skipped}")
async def main() -> None:
logging.basicConfig(level=logging.INFO)
bot = Bot(os.environ["BOT_TOKEN"])
dp = Dispatcher()
dp.include_router(router)
await dp.start_polling(bot) # allowed_updates is built from the handlers above
if __name__ == "__main__":
asyncio.run(main())
What each part does:
- The exception. aiogram turns every HTTP 403 from Telegram into
TelegramForbiddenError, and itsmessageholds Telegram’s description[5][4]. A response that carriesretry_afterbecomesTelegramRetryAfterinstead, with the wait in seconds[5][4]. - The order of the
exceptblocks.TelegramForbiddenErrorcomes before the generalTelegramAPIError, which is the base of every Telegram error in aiogram[4]. A 403 marks the chat inactive; any other failure is logged and the loop moves on, so one bad chat never stops the rest. - No retry on 403. Only the 429 is retried, after the wait Telegram asks for. The pause between sends is yours to tune; why it matters is in Telegram 429: Too Many Requests.
- Chat ids as 64-bit integers. SQLite’s
INTEGERholds a channel id such as-1001234567890. In PostgreSQL useBIGINT.
python-telegram-bot v21
The same rules, other names. A 403 becomes telegram.error.Forbidden[9], which was called Unauthorized before version 20.0[8]. In the broadcast loop:
from telegram.error import Forbidden
try:
await context.bot.send_message(chat_id, text)
except Forbidden as e:
set_active(chat_id, False)
For the status changes, python-telegram-bot’s own chatmemberbot.py example registers ChatMemberHandler(track_chats, ChatMemberHandler.MY_CHAT_MEMBER) and starts with application.run_polling(allowed_updates=Update.ALL_TYPES) so that the member updates reach it[10].
If you want the bot back in the chat
Nothing in your code can undo the removal. The Bot API has no method for a bot to join a chat[1]; users add bots to their groups and channels[3]. Ask an administrator of that chat to add the bot again. The my_chat_member update that follows flips the row back to active, and the next broadcast includes it.
If the bot should leave a chat on purpose, call leaveChat[1], and mark the chat inactive yourself at the same time: afterwards sends there fail with a 403, which in the Bot API server’s code is Forbidden: bot is not a member of ...[2].
On Livops
Livops does not filter or retry your sends; the handling above lives in your code. What Livops gives you is the place to run it:
- The bot as a Bot. A bot runs as the
bottype: always on, no public URL needed. Its exceptions and theskiplines from the loop are on the project’s Logs page and in the terminal withlivops logs <service> -f. - The table survives a deploy. The project has its own disk at
/app/data, and its path is inDATA_DIR, which is why the example builds the SQLite path from it. A file written anywhere else is not kept. See Files and data. - PostgreSQL when more than one service reads it. If a separate worker sends the broadcasts, keep the chats table in PostgreSQL: add it under Databases, and
DATABASE_URLis written into every service in the environment, including ones added later. Store chat ids asBIGINT. - The broadcast as a worker or a cron job. A
workeris an always-on background process with no public URL; acronservice runs on a schedule read in UTC. Either one must only send and never callgetUpdates, or it conflicts with the bot. The setup is in Cron and workers.
A bot, worker or cron job costs 19 credits a month (19,000 so’m); see Pricing.
Questions
Can the bot rejoin the group by itself?
No. The Bot API has no method for a bot to join a chat. Someone in the group or channel has to add it again, and then your bot gets a my_chat_member update with its new status, so you can mark the chat active.
Should I retry the message later?
No. The 403 stays until somebody adds the bot back, so a retry sends the same request and gets the same answer. Mark the chat inactive and skip it. Keep retries for 429 Too Many Requests, which asks you to wait and send again.
What is the difference between kicked and not a member?
Kicked means the bot was removed and banned from that chat; its status there is kicked. Not a member means its status is left, for example because it left the chat itself with leaveChat. Both are 403s, and for a sender both mean stop writing to this chat.
Is this the same as bot was blocked by the user?
It is the same idea in a different place. Blocked by the user is a private chat: one person blocked the bot. Kicked is a group, supergroup or channel: an administrator removed the bot. Handle both by marking the chat inactive.
Why did I not get a my_chat_member update?
Usually because the bot asks Telegram for a list of update types that leaves it out. Check allowed_updates in getUpdates or setWebhook. Telegram also keeps undelivered updates for at most 24 hours, so a bot that was down longer can miss one. Catching the 403 on send covers that case.
Does this error crash my bot?
Only if the exception escapes your code. In a broadcast loop, catch it around each send and carry on with the next chat. Without that, one group that removed the bot stops the loop for every chat after it.
Sources
- Telegram Bot API — Making requests, Update, getUpdates, setWebhook, ChatMemberUpdated, ChatMember, leaveChat (core.telegram.org). Checked .
- Telegram Bot API server source — telegram-bot-api/Client.cpp (raw.githubusercontent.com). Checked .
- Telegram — Bots, an introduction for developers (core.telegram.org). Checked .
- aiogram source — aiogram/exceptions.py (raw.githubusercontent.com). Checked .
- aiogram source — aiogram/client/session/base.py (raw.githubusercontent.com). Checked .
- aiogram docs source — ChatMemberUpdated filter (raw.githubusercontent.com). Checked .
- aiogram source — aiogram/dispatcher/dispatcher.py (raw.githubusercontent.com). Checked .
- python-telegram-bot source — telegram/error.py (raw.githubusercontent.com). Checked .
- python-telegram-bot source — telegram/request/_baserequest.py (raw.githubusercontent.com). Checked .
- python-telegram-bot example — examples/chatmemberbot.py (raw.githubusercontent.com). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your botRelated
- Telegram 403: Forbidden: bot was blocked by the user — how to handle itThe user blocked the bot, and Telegram refuses every message the bot sends them. Nothing is broken and a retry will not help: catch the 403, mark that user as inactive in your database, skip them in broadcasts, and mark them active again when they write to the bot.
- Telegram 400: Bad Request: chat not found — how to fix itThe bot asked Telegram for a chat it does not know. Either the chat_id is wrong (a typo, a channel id without its -100 prefix, a user's @username, an id cut to 32 bits), or it is right but this bot has never been in that chat: the user never pressed Start, the bot was never added to the group or channel, or the token belongs to a different bot.
- Telegram 400: Bad Request: not enough rights to send text messages to the chat — how to fix itBad Request: not enough rights to send text messages to the chat means the bot is in the group, but its permissions there do not allow this kind of message: the group's default permissions turn sending off for members, or the bot itself was restricted. Make the bot an administrator, or turn the permission back on; check with getChatMember for the bot's own id. In a channel the bot needs to be an administrator that can post.
- Telegram 400: Bad Request: group chat was upgraded to a supergroup chat — how to fix itThe group your bot writes to was upgraded to a supergroup, and the supergroup has a new chat id: the old one no longer takes messages. The error carries the new id in parameters.migrate_to_chat_id. Save it in place of the old id and send again, and handle the migrate_to_chat_id service message so the id is updated before the next send fails.
- Telegram 429: Too Many Requests, flood control: retry after N — how to fix itTelegram flood control (429 Too Many Requests) 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.
- Telegram bot hosting in 2026: the options comparedA Telegram bot needs a process that never stops, or a public HTTPS address for a webhook. On Livops it runs from a GitHub push for 19 credits a month (19,000 so'm). Here is how a VPS, Railway, Render, Fly.io and Vercel compare.
- aiogram bot hosting: how to deploy an aiogram 3 botAn aiogram 3 bot needs one process that never stops, the token in an environment variable, state kept outside memory and a clean exit on SIGTERM. On Livops you push a repository with bot.py and requirements.txt, and it runs for 19 credits a month (19,000 so'm), polling or webhook.
- python-telegram-bot hosting: deploying a v22 botA python-telegram-bot bot runs as one Application: run_polling() for polling, run_webhook() with the webhooks extra for a webhook. Both stop cleanly on SIGTERM. On Livops it runs from a push with bot.py and requirements.txt for 19 credits a month (19,000 so'm).
- Telegram 403: Forbidden: bot is not a member of the channel chat — how to fix itTelegram knows the channel, but your bot is not in it, so every send, edit or delete there fails with a 403. Usually the bot was never added (a public channel is found by its @username even so), it left with leaveChat, it was removed and then unbanned, or the token belongs to a different bot. Add the bot to the channel as an administrator that can post messages. The same error exists for supergroups and groups.