Telegram error 400: Bad Request: bad webhook: failed to resolve host
Last verified against Telegram Bot API reference
Bad Request: bad webhook: failed to resolve host: <detail varies>What error 400 means
setWebhook accepted the URL syntactically but Telegram's servers could not resolve the hostname to an address. The description begins bad webhook: failed to resolve host: and continues with the resolver's detail, commonly no address associated with hostname or Name or service not known. An older variant you may still find in library code reads bad webhook: getaddrinfo: Temporary failure in name resolution. All mean DNS lookup failed from Telegram's side.
Telegram verifies the host at registration, which is why this error appears on setWebhook rather than later. A typo, a brand-new DNS record that has not propagated, a private hostname, or an internal-only domain all produce it.
Once DNS is fixed the same setWebhook call succeeds; there is no state to clean up.
What it looks like
{"ok":false,"error_code":400,"description":"Bad Request: bad webhook: failed to resolve host: no address associated with hostname"}Why it happens
- Typo in the domain, or an environment-specific hostname (e.g.
app.internal) leaking into production config. - A DNS record created seconds before setWebhook, not yet visible to Telegram's resolvers.
- A tunnel URL that expired and no longer resolves.
- Split-horizon DNS where the name only exists inside your network.
How to fix Telegram error 400
- 1Run
dig +short your.hostfrom a public resolver (for example 1.1.1.1); if it returns nothing, fix DNS first. - 2Wait for propagation, then retry setWebhook.
- 3Confirm the hostname in your config matches the certificate CN exactly.
- 4Check
getWebhookInfoto confirm the new URL took effect.
How to stop it recurring
Make webhook registration a step that runs after DNS and TLS are confirmed reachable from the public internet, not during the first boot of a fresh host. Keep tunnel-based URLs out of persistent configuration.
Registration-time failures like this one are the easy half of webhook debugging, because setWebhook tells you immediately; delivery-time failures show up only in getWebhookInfo.last_error_message and are walked through in the webhook debugging guide. The other registration rules (HTTPS scheme, the four ports, certificate matching) are under webhook limits, and their errors are HTTPS url must be provided and the port-list rejection.
Official reference: Telegram Bot API reference. See all Telegram error codes or the Telegram limits and quotas.
Related codes
- 400: Bad Request: bad webhook: HTTPS url must be provided for webhookBad Request: bad webhook: HTTPS url must be provided for webhook
- 400: Bad Request: bad webhook: Webhook can be set up only on ports 80, 88, 443 or 8443Bad Request: bad webhook: Webhook can be set up only on ports 80, 88, 443 or…
- 409: Conflict: can't use getUpdates method while webhook is activeConflict: can't use getUpdates method while webhook is active; use…
Error 400 - quick answers
What does Telegram error 400 mean?
setWebhook accepted the URL syntactically but Telegram's servers could not resolve the hostname to an address. The description begins bad webhook: failed to resolve host: and continues with the resolver's detail, commonly no address associated with hostname or Name or service not known . An older variant you may still find in library code reads bad webhook: getaddrinfo: Temporary failure in name resolution .
How do I fix Telegram error 400?
1. Run dig +short your.host from a public resolver (for example 1.1.1.1); if it returns nothing, fix DNS first. 2. Wait for propagation, then retry setWebhook. 3. Confirm the hostname in your config matches the certificate CN exactly. 4. Check getWebhookInfo to confirm the new URL took effect.
Stop debugging Telegram by hand
Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.