Bad Request: message is not modified — Telegram bot error and how to fix it
Bad Request: message is not modified means your bot asked Telegram to edit a message into exactly what it already shows: the same text, caption and inline keyboard. It usually comes from a user pressing the same button twice or a refresh button with nothing new. Skip the edit when nothing changed, or catch this exact error and ignore it.
By Livops team, the people who build and run LivopsUpdated
The error, as the Telegram Bot API returns it when an edit would change nothing:
{"ok":false,"error_code":400,"description":"Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message"}
In short: your bot called editMessageText, editMessageCaption or editMessageReplyMarkup with exactly the text, caption and inline keyboard the message already shows, so Telegram refused the edit. It is harmless and usually comes from a user pressing the same button twice. Skip the edit when nothing changed, or catch this one error and ignore it; either way, still answer the callback query.
Each library wraps it in its own words:
| Library | What you see |
|---|---|
| aiogram 3 | TelegramBadRequest: Telegram server says - Bad Request: message is not modified: ...[4][5] |
| python-telegram-bot | telegram.error.BadRequest: Message is not modified: ...[7][8] |
| grammY | GrammyError: Call to 'editMessageText' failed! (400: Bad Request: message is not modified: ...)[11] |
| Telegraf | TelegramError: 400: Bad Request: message is not modified: ...[14] |
This page explains what the error means, lists where it comes from, and shows the two fixes — skip an edit that changes nothing, or catch this one error and ignore it — in aiogram, python-telegram-bot, grammY and Telegraf. It ends with what to check when the error stops the whole bot, and how it looks on Livops.
What does the error mean?
editMessageText, editMessageCaption and editMessageReplyMarkup change a message that is already in the chat instead of sending a new one, which Telegram says is most useful for messages with inline keyboards[1]. Telegram’s own advice is to edit the keyboard when a user toggles a setting or moves to a new page, rather than send a new message[2].
The error means the edit you asked for would leave the message exactly as it is. Telegram’s servers report this as MESSAGE_NOT_MODIFIED, and the Bot API server turns it into the text above with code 400 and the prefix Bad Request[3]. The message is not damaged and nothing was sent; the request was simply not needed.
Match the error by its description, not by its code alone: a failed request has ok set to false and the reason in description, while the contents of error_code are subject to change[1]. Many other mistakes are a 400 too.
Where it comes from, most common first
1. The user presses the same button twice
The first press edits the message into the new state. A second press of the same button — a double tap, or a press while the first edit is still on its way — asks for that same state again. The text and keyboard you build are identical to what is shown, and the edit fails.
2. A button that leads to where the user already is
- a “◀ Back” arrow on page 1, or “Next ▶” on the last page, that rebuilds the same page;
- a Refresh button when the data has not changed since the last refresh;
- a settings toggle or a choice in a list that is already selected.
3. The same content written in different markup
With parse_mode, the Bot API server turns HTML, Markdown or MarkdownV2 into plain text plus formatting entities before the edit goes to Telegram[3]. So <b>Total: 5</b> with HTML and *Total: 5* with MarkdownV2 both describe the text Total: 5 in bold: if only the markup language changes, the message itself may not, and the edit can be refused as not modified.
4. Only the caption or only the keyboard
editMessageCaption edits a caption, and editMessageReplyMarkup edits only the keyboard[1]. Sending the caption or the keyboard the message already has gives the same error: the message’s content and keyboard would both stay as they are.
How to fix it
Compare before you edit
The cleanest fix is not to send the edit. Keep the state the message shows — the page number, the selected option, a version of the data — and skip the edit when the new state is the same. Answer the callback query either way, so the button stops loading.
# aiogram 3: the buttons carry the page they lead to and the page shown now
@router.callback_query(F.data.startswith("page:"))
async def on_page(callback: CallbackQuery):
_, target, current = callback.data.split(":")
await callback.answer()
if target == current:
return # nothing would change
await callback.message.edit_text(render_page(int(target)), reply_markup=page_kb(int(target)))
Comparing text is harder than it looks. message.text holds plain text; the formatting is in its entities. To compare with text you send as HTML, rebuild the HTML from the message first: aiogram’s Message.html_text[6], python-telegram-bot’s Message.text_html[9]. The rebuilt HTML is not always written the way you wrote yours, so keep the except below as a safety net.
Catch this exact error and ignore it
When an identical edit is harmless — and it usually is — catch the bad request, check its text, and raise everything else.
aiogram 3. Telegram’s 400 is TelegramBadRequest, and its message is Telegram’s description[4][5]:
from aiogram.exceptions import TelegramBadRequest
try:
await callback.message.edit_text(text, reply_markup=kb)
except TelegramBadRequest as e:
if "message is not modified" not in e.message:
raise
python-telegram-bot. Telegram’s 400 is BadRequest[7][8]. The library removes the Bad Request: prefix and capitalizes the rest, so the text starts with Message is not modified[7]; compare in lower case:
from telegram.error import BadRequest
try:
await query.edit_message_text(text, reply_markup=kb)
except BadRequest as e:
if "message is not modified" not in e.message.lower():
raise
query.edit_message_text is the shortcut on the CallbackQuery[10].
grammY. API errors are GrammyError, with Telegram’s description and error_code on it[11]:
import { GrammyError } from "grammy";
try {
await ctx.editMessageText(text, { reply_markup: kb });
} catch (e) {
if (!(e instanceof GrammyError && e.description.includes("message is not modified"))) throw e;
}
ctx.editMessageText is grammY’s shortcut for the message the update is about[13].
Telegraf. API errors are TelegramError, with code and description getters[14]:
import { TelegramError } from "telegraf";
try {
await ctx.editMessageText(text, { reply_markup: kb });
} catch (e) {
if (!(e instanceof TelegramError && e.description.includes("message is not modified"))) throw e;
}
ctx.editMessageText is Telegraf’s shortcut too[16].
Write the check once — a small safe_edit helper, or the library’s error handler — rather than around every edit.
When it stops the whole bot
The error itself is harmless; an uncaught one is not always.
- grammY. Without
bot.catch, the default error handler logs the error, printsNo error handler was set!, and stops the bot if it runs withbot.start()[12]. Install a handler:bot.catch((err) => console.error(err.error)), and skip this error there if you like. - Telegraf. The default error handler sets the exit code to 1, logs the update and rethrows the error[15]. Replace it with
bot.catch((err, ctx) => { ... })[15]. - aiogram and python-telegram-bot keep running. aiogram’s polling logs
Cause exception while process update ...and moves on[17]; python-telegram-bot with no error handler logsNo error handlers are registered, logging exception.[18] Either way, the rest of that handler — everything after the failed edit — does not run.
On Livops
This error happens while the bot runs, when a user presses a button; a deploy does not press your buttons, so it can be green while a button misbehaves.
- Logs. The error line is on the project’s Logs page, and
livops logs <service> -ffollows it from the terminal; see CLI. Over MCP,get_logsreturns up to 5000 lines. - If it stops the bot right after a deploy. If an uncaught error stops the bot right after it starts, the deploy fails as
start_failed, with the bot’s last words on the Logs page. A bot’s old version is stopped before the new one starts, so the bot stays down until a deploy succeeds. See The app did not start. - Ship the fix with a push. Push the
try/exceptor the state check, and the new version replaces the old one.
A bot costs 19 credits a month (19,000 so’m); see Pricing.
Questions
What does message is not modified mean in a Telegram bot?
The bot called editMessageText, editMessageCaption or editMessageReplyMarkup, and the new text and keyboard are exactly what the message already shows. Telegram refuses an edit that changes nothing and answers with 400 Bad Request. Nothing is broken; the edit was simply not needed.
Is it safe to ignore message is not modified?
Yes, as long as you ignore only this exact error. The message already looks the way you wanted. Catch the library's bad request error, check that its text contains message is not modified, and raise everything else, so a real problem such as a message that cannot be edited still shows up in the log.
Why does it happen when a user presses the same button twice?
The first press already edited the message into the new state. The second press asks for the same state again, so the edit changes nothing. Pagination arrows on the first or last page, refresh buttons and settings toggles that land on the value already shown are the usual places.
My code sends different text, so why does Telegram say it is the same?
With parse_mode set, the markup is turned into plain text plus formatting entities before the edit reaches Telegram. Two strings written in different markup, for example HTML and MarkdownV2, can describe the same text and formatting, and then the edit may not change the message.
How can I avoid the error without try and except?
Compare before you edit. Keep the state the message shows, such as the page number or the selected option, in the callback data or in your storage, and skip the edit when the new state is the same. Still answer the callback query, so the button stops loading.
Can this error crash my bot?
It can if nothing catches it. grammY without bot.catch logs the error and stops the bot when it runs with bot.start, and Telegraf's default error handler rethrows it. Catch it where you edit, or install an error handler that ignores it.
Do I still have to answer the callback query when I skip the edit?
Yes. After a user presses a callback button, Telegram clients show a progress bar until the bot calls answerCallbackQuery, and Telegram says to call it even when no notification is needed. Answer it first, then skip or make the edit.
Sources
- Telegram Bot API — Making requests, Formatting options, Updating messages, editMessageText, editMessageCaption, editMessageReplyMarkup (core.telegram.org). Checked .
- Telegram — Bot features (Inline keyboards) (core.telegram.org). Checked .
- Telegram Bot API server source — telegram-bot-api/Client.cpp (raw.githubusercontent.com). Checked .
- aiogram source — aiogram/exceptions.py (raw.githubusercontent.com). Checked .
- aiogram source — aiogram/client/session/base.py (raw.githubusercontent.com). Checked .
- aiogram source — aiogram/types/message.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 source — telegram/_message.py (raw.githubusercontent.com). Checked .
- python-telegram-bot source — telegram/_callbackquery.py (raw.githubusercontent.com). Checked .
- grammY source — src/core/error.ts (raw.githubusercontent.com). Checked .
- grammY source — src/bot.ts (raw.githubusercontent.com). Checked .
- grammY source — src/context.ts (raw.githubusercontent.com). Checked .
- Telegraf source — src/core/network/error.ts (raw.githubusercontent.com). Checked .
- Telegraf source — src/telegraf.ts (raw.githubusercontent.com). Checked .
- Telegraf source — src/context.ts (raw.githubusercontent.com). Checked .
- aiogram source — aiogram/dispatcher/dispatcher.py (raw.githubusercontent.com). Checked .
- python-telegram-bot source — telegram/ext/_application.py (raw.githubusercontent.com). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your botRelated
- Bad Request: message to edit not found / message can't be edited — Telegram bot error and how to fix itBad Request: message to edit not found means Telegram has no message with that message_id in that chat for your bot: the pair is wrong, the message was deleted, or the bot left the group. Bad Request: message can't be edited means the message exists but the bot may not edit it, usually because the bot did not send it. Edit only messages the bot sent, take both ids from the same message, and use inline_message_id for inline messages.
- Bad Request: BUTTON_DATA_INVALID — Telegram bot error and how to fix itBad Request: BUTTON_DATA_INVALID means Telegram refused the callback_data of an inline keyboard button, almost always because it is longer than 64 bytes. The limit is in bytes, not characters: a Cyrillic letter takes 2 bytes and an emoji 3 or 4, so 40 characters can be too long. Put a short id in the button and keep the rest on your server, or use aiogram's CallbackData or python-telegram-bot's arbitrary_callback_data.
- Bad Request: query is too old and response timeout expired or query ID is invalid — how to fix itBad Request: query is too old and response timeout expired or query ID is invalid means answerCallbackQuery came too late for a button press, or got the wrong ID. The handler did slow work before answering, or the bot was down and is now working through presses that queued up. Answer the callback query first, do the slow work after, and ignore this error for stale presses.
- Bad Request: can't parse entities — Telegram bot error and how to fix itBad Request: can't parse entities means Telegram could not read the formatting in your message: with parse_mode set to HTML, Markdown or MarkdownV2, some text — usually a user's name, a username with an underscore, a price with a dot, or an unclosed tag — breaks the markup. Escape that text for the parse mode you use, send entities instead of parse_mode, or send it without parse_mode.
- 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.
- 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).
- Bad Request: message can't be deleted / message to delete not found — Telegram bot error and how to fix itBad Request: message can't be deleted means the message exists but your bot may not delete it: it is older than 48 hours, it belongs to someone else and the bot lacks the right, or it is a service message that can't be removed. Bad Request: message to delete not found means it is already gone or the chat_id and message_id do not match. Delete within 48 hours, give the bot can_delete_messages, and catch both errors.