# 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.

Source: https://livops.dev/en/guides/error-telegram-bot-was-blocked-by-the-user

By Livops team, the people who build and run Livops. Updated 23 November 2026.

The full error, as the Telegram Bot API returns it with error code 403[2]:

```text
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].

```python
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].

```python
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]:

```ts
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]:

```js
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]:

```python
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_member` is in the default set of updates. If your bot passes its own `allowed_updates` list to `getUpdates` or `setWebhook`, 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:

  ```sql
  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](https://livops.dev/en/guides/error-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 `bot` type: always on, no public URL needed. Its exceptions and your `mark_inactive` log lines are on the project's **Logs** page and in the terminal with `livops logs <service> -f`.
- **The users table in PostgreSQL.** Add PostgreSQL under **Databases**, and `DATABASE_URL` is written into every service in the environment, including ones added later. Keep the `blocked_at` flag there; a file next to the code is gone after the next deploy.
- **The broadcast as a worker.** Run the sender as a `worker` service in the same project: an always-on background process with no public URL, with the same database variables. It must only send and never call `getUpdates`, or it conflicts with the bot — see [Conflict: terminated by other getUpdates request](https://livops.dev/en/guides/error-telegram-conflict-getupdates).

  ```json
  {
    "kind": "worker",
    "start": ".venv/bin/python sender.py"
  }
  ```

- **A broadcast at a fixed time.** A `cron` service 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](https://livops.dev/en/docs/cron-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](https://livops.dev/en/docs/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

1. [Telegram Bot API — Making requests, Update, getUpdates](https://core.telegram.org/bots/api). Checked 23 November 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 23 November 2026.
3. [Telegram — Bots, an introduction for developers](https://core.telegram.org/bots). Checked 23 November 2026.
4. [aiogram — Errors](https://docs.aiogram.dev/en/latest/dispatcher/errors.html). Checked 23 November 2026.
5. [aiogram source — aiogram/client/session/base.py](https://raw.githubusercontent.com/aiogram/aiogram/dev-3.x/aiogram/client/session/base.py). Checked 23 November 2026.
6. [aiogram source — aiogram/exceptions.py](https://raw.githubusercontent.com/aiogram/aiogram/dev-3.x/aiogram/exceptions.py). Checked 23 November 2026.
7. [aiogram 2.x source — aiogram/utils/exceptions.py](https://raw.githubusercontent.com/aiogram/aiogram/dev-2.x/aiogram/utils/exceptions.py). Checked 23 November 2026.
8. [aiogram — ChatMemberUpdated filter](https://docs.aiogram.dev/en/latest/dispatcher/filters/chat_member_updated.html). Checked 23 November 2026.
9. [python-telegram-bot — telegram.error](https://docs.python-telegram-bot.org/en/stable/telegram.error.html). Checked 23 November 2026.
10. [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 23 November 2026.
11. [python-telegram-bot wiki — Frequently requested design patterns](https://github.com/python-telegram-bot/python-telegram-bot/wiki/Frequently-requested-design-patterns). Checked 23 November 2026.
12. [grammY source — src/core/error.ts](https://raw.githubusercontent.com/grammyjs/grammY/main/src/core/error.ts). Checked 23 November 2026.
13. [Telegraf source — src/core/network/error.ts](https://raw.githubusercontent.com/telegraf/telegraf/v4/src/core/network/error.ts). Checked 23 November 2026.
14. [grammY — Scaling up IV, flood limits](https://grammy.dev/advanced/flood). Checked 23 November 2026.
