Telegram 403: Forbidden: bot was blocked by the user — how to handle it
The 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.
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 blocked by the user
Each library wraps it in its own words:
| Library | What you see |
|---|---|
| aiogram 3 | TelegramForbiddenError: Telegram server says - Forbidden: bot was blocked by the user[5][6] |
| python-telegram-bot | telegram.error.Forbidden: Forbidden: bot was blocked by the user[10] |
| grammY | GrammyError: Call to 'sendMessage' failed! (403: Forbidden: bot was blocked by the user)[12] |
| Telegraf | TelegramError: 403: Forbidden: bot was blocked by the user[13] |
This page explains what the error means, why it shows up in bulk during broadcasts, how to catch it in each of the four libraries, and how to keep a list of active users so the bot stops writing to people who left.
What does the error mean?
The user blocked the bot. Telegram turns its internal USER_IS_BLOCKED into this 403 for every message the bot tries to send that user[2]. It is not a bug in your code, not a token problem and not a rate limit; the message was simply not delivered, and the next one will not be either, until the user unblocks the bot.
Bots cannot start conversations: a user must write to the bot or add it to a group first[3]. So the bot can only ever reach people who chose to talk to it, and blocking is how they take that back.
The same situation has a few relatives, all 403s, all meaning “stop sending here”[2][7]:
| Description | Meaning |
|---|---|
Forbidden: bot was blocked by the user |
The user blocked the bot |
Forbidden: user is deactivated |
The user deleted their account |
Forbidden: bot was kicked from the group chat (or supergroup chat, channel chat) |
The bot was removed from that chat |
Forbidden: bot is not a member of the channel chat (or supergroup chat, group chat) |
The bot is not in that chat |
bot can't initiate conversation with a user |
The user never started a chat with the bot |
Telegram notes that 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.
Why it appears in broadcasts
In normal use a blocked user stops sending messages, so the bot has nothing to reply to and never sees the error. A broadcast — a newsletter, a reminder, an announcement to everyone in the database — is where the bot writes first, and every user who blocked it since they last spoke returns a 403. In a large audience that can be a sizeable share of the list, and the share grows with every broadcast if nothing is ever marked.
The python-telegram-bot wiki puts it plainly: even with every user’s ID, you cannot know whether someone has blocked the bot in the meantime, so wrap each send in a try/except for Forbidden[11].
Catch it in each library
The pattern is the same everywhere: try to send; on 403, mark the chat inactive and move on; on anything else, raise. Use your own mark_inactive(), for example an UPDATE in your database.
aiogram 3
A 403 from Telegram becomes TelegramForbiddenError[4][5]; its message holds Telegram’s description[6].
from aiogram import Bot
from aiogram.exceptions import TelegramForbiddenError
async def send(bot: Bot, chat_id: int, text: str) -> bool:
try:
await bot.send_message(chat_id, text)
return True
except TelegramForbiddenError as e:
await mark_inactive(chat_id, reason=e.message)
return False
python-telegram-bot
A 403 becomes telegram.error.Forbidden[9][10], which before version 20.0 was called Unauthorized[9].
from telegram.error import Forbidden
async def send(bot, chat_id: int, text: str) -> bool:
try:
await bot.send_message(chat_id, text)
return True
except Forbidden as e:
await mark_inactive(chat_id, reason=e.message)
return False
grammY
Every Bot API error is a GrammyError carrying error_code and description[12]:
import { GrammyError, type Bot } from "grammy";
async function send(bot: Bot, chatId: number, text: string): Promise<boolean> {
try {
await bot.api.sendMessage(chatId, text);
return true;
} catch (err) {
if (err instanceof GrammyError && err.error_code === 403) {
await markInactive(chatId, err.description);
return false;
}
throw err;
}
}
Telegraf
TelegramError exposes the error code as code and Telegram’s text as description[13]:
const { TelegramError } = require('telegraf');
async function send(telegram, chatId, text) {
try {
await telegram.sendMessage(chatId, text);
return true;
} catch (err) {
if (err instanceof TelegramError && err.code === 403) {
await markInactive(chatId, err.description);
return false;
}
throw err;
}
}
aiogram 2 (older code)
aiogram 2 raised BotBlocked for this description, alongside UserDeactivated, BotKicked and CantInitiateConversation, all subclasses of Unauthorized[7]. Catch Unauthorized to handle them together.
Mark users inactive, and active again
Do not wait for a broadcast to discover who blocked the bot. Telegram sends a my_chat_member update when the bot’s status in a chat changes, and in a private chat it comes only when the user blocks or unblocks the bot[1]. The python-telegram-bot wiki calls my_chat_member the most reliable way to keep track of your users[11].
In aiogram, filter the transition from member to not-member[8]:
from aiogram import F, Router
from aiogram.filters import IS_MEMBER, IS_NOT_MEMBER, ChatMemberUpdatedFilter
from aiogram.types import ChatMemberUpdated
router = Router()
@router.my_chat_member(F.chat.type == "private", ChatMemberUpdatedFilter(IS_MEMBER >> IS_NOT_MEMBER))
async def on_blocked(event: ChatMemberUpdated) -> None:
await mark_inactive(event.chat.id, reason="blocked")
@router.my_chat_member(F.chat.type == "private", ChatMemberUpdatedFilter(IS_NOT_MEMBER >> IS_MEMBER))
async def on_unblocked(event: ChatMemberUpdated) -> None:
await mark_active(event.chat.id)
Two details make this work:
-
Receive the update.
my_chat_memberis in the default set of updates. If your bot passes its ownallowed_updateslist togetUpdatesorsetWebhook, include"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]. -
Keep the flag in a database, not in memory, so a restart does not forget it. A column is enough:
ALTER TABLE users ADD COLUMN blocked_at timestamptz; -- on 403 or a my_chat_member block: UPDATE users SET blocked_at = now() WHERE chat_id = $1; -- on unblock, or any new message from the user: UPDATE users SET blocked_at = NULL WHERE chat_id = $1; -- the broadcast list: SELECT chat_id FROM users WHERE blocked_at IS NULL;
To message everyone you need their chat ids stored somewhere you can read them slowly[14]; the same table carries the flag.
Do not retry
A 403 is final for that user until they act. Retrying it, with or without a delay, sends the same request and gets the same answer. Keep retries for the errors that ask for them: 429 Too Many Requests means wait retry_after seconds and send again, while 403 means skip. A broadcast loop handles both — see Telegram 429: Too Many Requests for the waiting part.
On Livops
Livops does not filter your sends or retry them; 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 yourmark_inactivelog lines are on the project’s Logs page and in the terminal withlivops logs <service> -f. -
The users table in PostgreSQL. Add PostgreSQL under Databases, and
DATABASE_URLis written into every service in the environment, including ones added later. Keep theblocked_atflag there; a file next to the code is gone after the next deploy. -
The broadcast as a worker. Run the sender as a
workerservice in the same project: an always-on background process with no public URL, with the same database variables. It must only send and never callgetUpdates, or it conflicts with the bot — see Conflict: terminated by other getUpdates request.{ "kind": "worker", "start": ".venv/bin/python sender.py" } -
A broadcast at a fixed time. A
cronservice can queue tomorrow’s broadcast on a schedule read in UTC:0 4 * * *is 09:00 in Tashkent. The syntax is in Cron and workers.
A bot, worker or cron job costs 19 credits a month (19,000 so’m). One 500 MB database per team is free; see Pricing.
Questions
Can I unblock myself or make the user unblock the bot?
No. Only the user can unblock the bot, from the chat with it. Until they do, every message to them returns this 403. Your bot is told through a my_chat_member update when they block it, and again when they unblock.
Should I retry the message later?
No. The error does not go away with time, and retries only add load and log noise. Mark the user as inactive and skip them. When they unblock the bot and write to it again, mark them active.
Does this error crash my bot?
Only if the exception escapes your code. Give your library an error handler for exceptions raised in handlers, and wrap each send of a broadcast in a try block. Without one, a single blocked user can stop the loop for everyone after them.
How do I know how many users blocked my bot?
Count them yourself. Record a my_chat_member update in a private chat, or a 403 on send, as blocked, with the time, and count the rows where that time is set.
Is user is deactivated the same thing?
Almost. Forbidden: user is deactivated means the account was deleted. Handle it the same way, but that user will not come back, so you can delete them instead of marking them inactive.
Is a blocked user a problem for my bot's rate limits?
No, the 403 is not flood control. A 429 Too Many Requests is a different error that asks you to wait and send again. A broadcast needs both: wait on 429, skip on 403.
Sources
- Telegram Bot API — Making requests, Update, getUpdates (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 — Errors (docs.aiogram.dev). Checked .
- aiogram source — aiogram/client/session/base.py (raw.githubusercontent.com). Checked .
- aiogram source — aiogram/exceptions.py (raw.githubusercontent.com). Checked .
- aiogram 2.x source — aiogram/utils/exceptions.py (raw.githubusercontent.com). Checked .
- aiogram — ChatMemberUpdated filter (docs.aiogram.dev). Checked .
- python-telegram-bot — telegram.error (docs.python-telegram-bot.org). Checked .
- python-telegram-bot source — telegram/request/_baserequest.py (raw.githubusercontent.com). Checked .
- python-telegram-bot wiki — Frequently requested design patterns (github.com). Checked .
- grammY source — src/core/error.ts (raw.githubusercontent.com). Checked .
- Telegraf source — src/core/network/error.ts (raw.githubusercontent.com). Checked .
- grammY — Scaling up IV, flood limits (grammy.dev). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your botRelated
- 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 429: Too Many Requests: retry after N — how to fix itTelegram'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.
- Conflict: terminated by other getUpdates request — how to fix itTelegram is telling your bot that another process called getUpdates with the same token and took the connection over. Two copies of the bot are polling at once: stop the other one (usually the copy still running on your computer or an old server), or get a new token from @BotFather, and the error stops.
- 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).
- grammY bot deploy: polling, webhooks and hostingDeploy a grammY bot as one always-on Node.js process: bot.start() for polling, or webhookCallback() behind an HTTP server, with bot.stop() on SIGTERM. On Livops a repository with grammy in package.json runs as a bot from every push, for 19 credits a month (19,000 so'm).
- Telegraf bot hosting: deploying a Telegraf 4 bot on Node.jsA Telegraf bot is one Node.js process: bot.launch() for polling, or bot.webhookCallback() behind an HTTP server for a webhook, with bot.stop() on SIGTERM. On Livops a repository with telegraf in package.json is run as a bot from every push, for 19 credits a month (19,000 so'm).