Telegram error 400: Bad Request: bad webhook: Webhook can be set up only on ports 80, 88, 443 or 8443
Last verified against Telegram Bot API reference
Bad Request: bad webhook: Webhook can be set up only on ports 80, 88, 443 or 8443What error 400 means
The URL given to setWebhook includes an explicit port that is not one of the four Telegram supports. The Bot API documentation and FAQ both list them: 443, 80, 88 and 8443. Any other port, most commonly 3000, 5000, 8000 or 8080 from a development server, is rejected at registration time.
The description includes the literal port list, so you will sometimes see it phrased in guides as port 8080 is not supported; the actual text returned is the one above. Only a local Bot API server lifts this restriction ('use any port for the webhook').
Because the webhook was never registered, Telegram keeps delivering to the previous webhook or to nothing. getWebhookInfo will show the old state, which is the fastest way to confirm what actually happened after a failed registration. If your bot previously used polling and this setWebhook failed, the bot silently keeps polling mode, and a later poller may hit the 409 webhook conflict once someone registers the corrected URL.
The error appears in libraries as a plain 400: python-telegram-bot raises telegram.error.BadRequest from bot.set_webhook(...), aiogram raises TelegramBadRequest, and the Node libraries reject the setWebhook promise with the description text. Frameworks that auto-register webhooks on boot often log and swallow this, which turns a one-line configuration mistake into a bot that starts 'successfully' and never receives an update. Make webhook registration a hard-fail step in deployment.
To reproduce and confirm the rule, call setWebhook with an explicit port and read the body: curl "https://api.telegram.org/bot<TOKEN>/setWebhook?url=https://example.com:8080/hook" returns exactly this description, while the same URL on 8443 registers and shows up in getWebhookInfo.
What it looks like
{"ok":false,"error_code":400,"description":"Bad Request: bad webhook: Webhook can be set up only on ports 80, 88, 443 or 8443"}Why it happens
- Using the app's listening port directly in the webhook URL instead of a reverse proxy on 443.
- A tunnel or PaaS that exposes a non-standard port.
- Copying an internal health-check URL into the webhook configuration.
- A container platform mapping the public HTTPS listener to a random high port that ends up in the URL.
How to fix Telegram error 400
- 1Put the app behind a TLS-terminating proxy or load balancer on 443 (or 8443) and register that public URL.
- 2Omit the port entirely when using the default HTTPS port.
- 3Verify with
getWebhookInfoafter the change thaturlshows the corrected value. - 4Send a test message to the bot and watch your endpoint logs for the POST from Telegram.
- 5If you must keep a custom port, run the local Bot API server, which allows any port.
How to stop it recurring
Separate the internal listening port from the public webhook URL in configuration, and validate the public URL's port against the allowed list at startup. Document the four ports in your runbook so the next deploy does not repeat the mistake. The full webhook constraint table (scheme, ports, max_connections, secret_token) is under webhook limits, and endpoint-side failures are covered in the webhook debugging guide.
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: failed to resolve hostBad Request: bad webhook: failed to resolve host: <detail varies>
- 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?
The URL given to setWebhook includes an explicit port that is not one of the four Telegram supports. The Bot API documentation and FAQ both list them: 443, 80, 88 and 8443. Any other port, most commonly 3000, 5000, 8000 or 8080 from a development server, is rejected at registration time.
How do I fix Telegram error 400?
1. Put the app behind a TLS-terminating proxy or load balancer on 443 (or 8443) and register that public URL. 2. Omit the port entirely when using the default HTTPS port. 3. Verify with getWebhookInfo after the change that url shows the corrected value. 4. Send a test message to the bot and watch your endpoint logs for the POST from Telegram. 5. If you must keep a custom port, run the local Bot API server, which allows any port.
Stop debugging Telegram by hand
Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.