getWebhookInfo: check why your Telegram webhook is not working
Call https://api.telegram.org/bot<TOKEN>/getWebhookInfo. An empty url means no webhook is set. A pending_update_count that keeps growing with a recent last_error_date means Telegram cannot deliver, and last_error_message says why: a non-2XX answer, a timeout, a TLS error. Fix the endpoint, then reset with setWebhook, or deleteWebhook with drop_pending_updates to discard the backlog.
By Livops team, the people who build and run LivopsUpdated
A webhook bot that goes quiet usually has nothing in its own logs, because the failing request never reached it. Telegram knows what went wrong, and getWebhookInfo is how you ask. This page shows how to call it, what every field of the answer means in the Bot API’s own definitions, what the common last_error_message values mean — taken from the source code of the Bot API server that produces them — and how to reset the webhook once the endpoint is fixed. It ends with what Livops does with the same call.
How do you call getWebhookInfo?
Every Bot API method is an HTTPS request to https://api.telegram.org/bot<token>/METHOD_NAME, by GET or POST[1]. getWebhookInfo takes no parameters and returns a WebhookInfo object; if the bot uses getUpdates, the object has an empty url[1].
curl -s "https://api.telegram.org/bot<TOKEN>/getWebhookInfo"
Replace <TOKEN> with the token from @BotFather. The token is the bot: run this in your own terminal, not in a shared CI log or a chat. An illustrative answer from a webhook that is failing:
{
"ok": true,
"result": {
"url": "https://bot.example.com/telegram/webhook",
"has_custom_certificate": false,
"pending_update_count": 37,
"ip_address": "203.0.113.10",
"last_error_date": 1764061200,
"last_error_message": "Wrong response from the webhook: 502 Bad Gateway",
"max_connections": 40
}
}
Every WebhookInfo field
| Field | Type | The Bot API’s definition[1] | What to look for |
|---|---|---|---|
url |
String | Webhook URL, may be empty if webhook is not set up | Is it the address you expect, exactly, path included? |
has_custom_certificate |
Boolean | True, if a custom certificate was provided for webhook certificate checks | true only if you uploaded a self-signed certificate with setWebhook |
pending_update_count |
Integer | Number of updates awaiting delivery | Near 0 when delivery works; growing when it does not |
ip_address |
String, optional | Currently used webhook IP address | The address Telegram resolved your host to. Is it your server? |
last_error_date |
Integer, optional | Unix time for the most recent error that happened when trying to deliver an update via webhook | How long ago, compared with now |
last_error_message |
String, optional | Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook | Why — see the next section |
last_synchronization_error_date |
Integer, optional | Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters | A problem on Telegram’s side, not your endpoint’s |
max_connections |
Integer, optional | The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery | 40 unless you set it; 1–100 on the cloud Bot API[1] |
allowed_updates |
Array of String, optional | A list of update types the bot is subscribed to. Defaults to all update types except chat_member, message_reaction, and message_reaction_count |
Missing an update type your code waits for, such as callback_query? |
Optional fields may not be returned when irrelevant[1]. In the Bot API server’s code, last_error_date and last_error_message appear only after an error, allowed_updates only when it differs from the default, ip_address only when a webhook is set — as <unknown> until an address is known — and last_synchronization_error_date only when there was one[4].
Two details change how you read the error. It is not cleared when deliveries start working again: the server resets it only when the webhook is set again or removed[4]. So an old last_error_date with a pending_update_count of 0 is a problem you already fixed. And it is only about delivery: an error in your handler that still returns 200 is invisible here.
Reading the answer
urlis empty. No webhook is set; the bot is expected to poll withgetUpdates[1]. If you set one and it is empty now, it failed the check Telegram runs when it is set (below), or something calleddeleteWebhookorsetWebhookwith an emptyurl, which removes it[1].urlis set,pending_update_countis 0, no recent error. Telegram is delivering. If the bot still does not answer, the problem is after delivery: your handler, its logs, the token it uses to reply.pending_update_countkeeps growing andlast_error_dateis recent. Telegram cannot deliver. Readlast_error_message. Undelivered updates are kept for at most 24 hours[1].- A polling bot, and
urlis not empty. A webhook left over from another host is taking the updates, andgetUpdatesfails withConflict: can't use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first[4]. Remove it withdeleteWebhook.
What last_error_message means
These are the messages the open-source Bot API server writes[1], as they appear in its code. Each one is something Telegram saw when it connected to your address.
Wrong response from the webhook: 502 Bad Gateway
Your address answered, but with a status other than 2XX; the message carries the status code and reason[5]. Telegram repeats a request that did not get a 2XX and gives up after a reasonable number of attempts[1]. In the server’s code the delay between attempts for one update doubles up to between 60 and 120 seconds[5][6], a Retry-After header in your answer is honoured up to an hour[5][10], and an update whose next attempt would fall past its expiry is dropped[5].
- 500 comes from your code: an exception in the handler. Your logs have it.
- 502, 503, 504 usually come from a proxy in front of the app that could not reach it: the app is down, still starting, or listening on another port or on
localhost. See 502 Bad Gateway. - 401, 403 are often your own secret check refusing the request — a
secret_tokenthat no longer matches what the code expects. - 404 means the path is wrong: the
urlyou set does not match the route the app serves. - 410 is treated specially: if every answer is 410 for 23 hours, the server closes the webhook[5][6].
Read timeout expired
Telegram connected and sent the update, but your server did not finish answering in time[7]. The handler does slow work — an API call, a database query, a large reply — before it responds. Answer quickly and do the work after, or in a queue.
Webhook connection closed
The connection was closed without an answer[5]: the process crashed or restarted mid-request, or a proxy dropped the connection.
SSL error {…} and Can't create an SSL connection
The TLS handshake with your address failed; SSL error is followed by OpenSSL’s own error text in braces[9], and Can't create an SSL connection is the server failing to start TLS with your host[5]. Telegram’s webhook guide lists what it needs: TLS 1.2 or newer, a certificate whose root it trusts, the full chain including intermediate certificates — a browser may accept an incomplete chain, a webhook will not — and a certificate that matches the domain[2][3]. To check what Telegram sees:
openssl s_client -tls1_2 -connect bot.example.com:443 -servername bot.example.com
Errors setWebhook returns instead
Some problems stop the webhook from being set at all. Telegram checks the address when you call setWebhook, and a failure comes back as the call’s error, Bad Request: bad webhook: followed by the reason, with the webhook left unset[4]:
| What setWebhook says | Why |
|---|---|
Bad Request: bad webhook: An HTTPS URL must be provided for webhook |
The url is http://[5] |
Bad Request: bad webhook: Webhook can be set up only on ports 80, 88, 443 or 8443 |
Any other port[5] |
Bad Request: bad webhook: Failed to resolve host: … |
The domain has no DNS record Telegram can resolve[8] |
Bad Request: bad webhook: IP address … is reserved |
The host resolves to a private or reserved address[5] |
Bad Request: bad webhook: IPv6-only addresses are not allowed |
The host has only an IPv6 address; webhooks need IPv4[5][2] |
Bad Request: invalid webhook URL specified |
The url does not parse as a URL[4] |
Bad Request: secret token is too long / secret token contains illegal characters |
secret_token is over 256 characters or uses characters outside A-Z a-z 0-9 _ -[4][1] |
Resetting the webhook
Throw the backlog away, if the waiting updates are stale — a broken week’s worth of /start commands, say. drop_pending_updates drops all pending updates[1]:
curl -s "https://api.telegram.org/bot<TOKEN>/deleteWebhook?drop_pending_updates=true"
deleteWebhook is also how you go back to polling[1]. Without drop_pending_updates, the waiting updates are delivered by the next getUpdates or webhook.
Set it again with a secret. secret_token, 1–256 characters of A-Z, a-z, 0-9, _ and -, is sent back in the X-Telegram-Bot-Api-Secret-Token header of every webhook request, so your code can tell Telegram from anybody else[1]. Setting the webhook also resets last_error_message[4], so the next check shows only new errors:
curl -s "https://api.telegram.org/bot<TOKEN>/setWebhook" \
-d url=https://bot.example.com/telegram/webhook \
-d secret_token=<SECRET> \
-d max_connections=40
Add -d drop_pending_updates=true to do both in one call[1], and allowed_updates if you want only some update types; it is passed as a JSON list[1]. Then check the secret, and answer before the slow work:
app.post('/telegram/webhook', express.json(), (req, res) => {
if (req.get('X-Telegram-Bot-Api-Secret-Token') !== process.env.WEBHOOK_SECRET) {
return res.sendStatus(401)
}
res.sendStatus(200)
handleUpdate(req.body).catch((err) => console.error(err))
})
Answering first trades a retry for speed: if the process dies after the 200, Telegram will not send that update again. For an order or a payment, store the update first and answer after, and de-duplicate on update_id.
Finally, call getWebhookInfo again after sending the bot a message: the url should be yours, pending_update_count should fall to 0, and no new last_error_date should appear.
On Livops
A webhook bot on Livops never calls setWebhook itself; the platform owns that half:
- Setting it. Switch the bot’s Connection to Telegram to Webhook in its settings. On each deploy, once the new version answers on
PORT, Livops tells Telegram the address — the platform’s hook address, which runs behind Cloudflare — with aWEBHOOK_SECRETit generates, using the token inBOT_TOKEN. Requests to the path without the secret header are refused before they reach your code. Your code listens onPORT, receives onWEBHOOK_PATHand checksWEBHOOK_SECRET. - The build log says when the webhook was set, and to which address. If Telegram refuses, the log says the webhook was not set, with Telegram’s own sentence, and the same sentence is shown on the project; the deploy itself does not fail, and the next check tries again.
- Watching. About every ten minutes the platform calls
getWebhookInfowith the bot’s token. The project page shows the waiting count and the last delivery error — only an error from the last half hour or so, and newer than the moment the webhook was set, so a fixed problem does not linger. You are notified when deliveries start failing and again when they recover, once each, not on every check. - Repairing it. If the webhook points somewhere else — your code called
setWebhook, or a script randeleteWebhook— the next check puts the platform’s address back. A revoked token shows Telegram’s answer on the project instead. - Polling bots are checked too, with the same read-only call: you are told if a webhook is set (so polling receives nothing) or if messages wait and the bot takes none of them between two checks.
- Stopping. Switching a bot back to polling deletes the webhook and keeps the waiting updates; a project stopped for unpaid credits keeps them too, for when it starts again; deleting the project drops them.
If the error is a 502 from the app itself, the Livops proxy answers 502 with application is not responding when the app does not accept the connection — usually an app listening on localhost or another port; see 502 Bad Gateway. How the two modes compare is in Webhook vs polling. A bot costs 19 credits a month (19,000 so’m) in either mode; see Pricing.
Questions
How do I check my Telegram bot's webhook?
Open https://api.telegram.org/bot<TOKEN>/getWebhookInfo with your token in place of <TOKEN>, in a browser or with curl. It needs no parameters and returns the webhook's address, how many updates are waiting, and the last delivery error.
Why is the url empty in getWebhookInfo?
No webhook is set. Telegram returns an empty url when the bot uses getUpdates, and a setWebhook call that fails Telegram's check of the address leaves no webhook set. Set it again with setWebhook and read the error it returns.
What does pending_update_count mean?
The number of updates waiting to be delivered. A webhook that works keeps it near zero. A number that grows from one check to the next, with a recent last_error_date, means Telegram is failing to deliver. Updates are kept for at most 24 hours.
Does last_error_message clear when the webhook starts working?
No. It stays until the next error replaces it or the webhook is set or deleted again, so compare last_error_date with the current time before you trust it. An error from yesterday on a bot whose pending_update_count is zero is history.
How do I clear the queue of pending updates?
Call deleteWebhook with drop_pending_updates=true, or pass drop_pending_updates=true to setWebhook when you set the address again. Without it, the waiting updates are delivered once deliveries work.
What does Wrong response from the webhook mean?
Your server answered, but not with a 2XX status. The message carries the status and its reason, for example 502 Bad Gateway when a proxy in front of the app could not reach it. Telegram retries the update with growing delays, so fix the endpoint and the backlog drains.
Do I need to call setWebhook on Livops?
No. Switch the bot to webhook in its settings and Livops sets the webhook with a secret it generates, checks getWebhookInfo about every ten minutes, shows the waiting count and the latest error on the project page, and puts the webhook back if something else changed it.
Sources
- Telegram Bot API — getWebhookInfo, WebhookInfo, setWebhook, deleteWebhook, getUpdates (core.telegram.org). Checked .
- Telegram — Marvin's Marvellous Guide to All Things Webhook (core.telegram.org). Checked .
- Telegram — Bots FAQ (core.telegram.org). Checked .
- telegram-bot-api source — telegram-bot-api/Client.cpp (raw.githubusercontent.com). Checked .
- telegram-bot-api source — telegram-bot-api/WebhookActor.cpp (raw.githubusercontent.com). Checked .
- telegram-bot-api source — telegram-bot-api/WebhookActor.h (raw.githubusercontent.com). Checked .
- TDLib source — tdnet/td/net/HttpConnectionBase.cpp (raw.githubusercontent.com). Checked .
- TDLib source — tdutils/td/utils/port/IPAddress.cpp (raw.githubusercontent.com). Checked .
- TDLib source — tdnet/td/net/SslStream.cpp (raw.githubusercontent.com). Checked .
- TDLib source — tdnet/td/net/HttpQuery.cpp (raw.githubusercontent.com). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your botRelated
- Telegram bot webhook vs polling: which one to usePolling means your bot asks Telegram for updates in a loop; a webhook means Telegram POSTs each update to your HTTPS address. Polling is simpler and needs no address; a webhook needs HTTPS but no always-running loop. A bot uses one or the other, never both. On Livops both run for the same 19 credits a month.
- 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.
- 502 Bad Gateway after deploying: what it means and how to fix itThe proxy in front of your app reached for it and got no valid answer: nothing was listening on the port it tried, or the process closed the connection mid-request. After a deploy that is almost always one of five things: the app listens on the wrong port or on 127.0.0.1, it crashed on start, it was still starting, it ran out of memory, or the proxy points at the wrong port. The app's own log says which.
- 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.
- Is the Telegram Bot API free? Limits and costs in 2026Yes. Telegram charges nothing to create a bot or to call the Bot API, and bots message their users at no cost. What costs money is around it: the server the bot runs on, paid broadcasts above about 30 messages a second, and Telegram Stars when you sell digital goods. The free API has limits: about one message a second per chat, 20 a minute per group, 20 MB downloads and 50 MB uploads, more with a local Bot API server.