Telegram gets timeout error when trying to send bot updates

Hi. I'm using pythonanywhere for hosting a webhook server for a Telegram bot. Apprently Telegram gets a timeout error when trying to send the updates.

enter image description here

A free account only has one worker so, if your web app is busy with another request that takes a long time, the webhook will have to wait for that request to finish before it can be handled.

I have the same issue. I never had any issues until 5 ou 6 days ago. I make the webhook send the request when the app is not busy and it fails instantly.

I just sent a POST request from my local machine to the webhook endpoint and the PythonAnywhere responded, but when I do the same from the Telegram bot, it gets the same error as above.

And this is recent. I've been reading the logs and everything was working fine until between 13 and 15 of this month.

What do you see in your logs? What is your web app doing before the timeout? Do you log anything about it?

My app is a Telegram bot that manages a channel and is idle most of the time.

The app is basically the following: We have a react app hosted at Vercel which the users send some data to a Telegram channel via PythonAnywhere. At the channel, the bot handles some users text commands, sending them to Pythonanywhere via Webhooks. The first part is working fine, but the latter stopped working recently. This app has been working for nearly one year.

I log every JSON based POST request, which are sent by Telegram's webhook. I noticed that after the date I mentioned, my app didn't received any requests from the webhook, even when the users interact with the bot. Telegram's getWebhookInfo shows there are nearly 30 requests queued though.

What do you see in your access log? Do you see incoming requests?

No incoming requests since 15 Oct.

If there are no requests logged, then the most likely cause is that they are not reaching PythonAnywhere. Check the address that you're using for the webhook.

I just tested the webhook using and I just received all queued requests at the same time. Now, I changed it back to the correct PythonAnywhere's endpoint and got the same "Connection timed out" error again.

So, I believe something has changed in PythonAnywhere's roughly a week ago that is now blocking requests coming from Telegram.

Yeah, this problem is fairly recent for me too. It appears somewhere between Telegram and PythonAnywhere, the request gets blocked. Has PythonAnywhere received any requests from Telegram in recent days? I see no trace of the request in access.log or error.log.

Specifically, requests from Telegram to PythonAnywhere are blocked somewhere before arriving at the app.

However, requests from PythonAnywhere to Telegram are working fine since I use both.

Is it possible to use Cloudflare as a reverse proxy for PythonAnywhere? This could potentially solve the problem

You can't use Cloudflare with a free account, no -- you need control over the domain name used for the site in order to set up the proxying, and of course that's not possible with a website at

Perhaps you could get in touch with Telegram and try to get more details from them about whether they're queuing stuff up? I appreciate that they're a large organisation so it might be hard to get in touch with a real person there...

Well, after some testing and tweaking, I've found the solution to this problem is to migrate to another host, which in my case is

Everything is working fine again.

im having the same problem on paid and free account since this time. what has happened?

What IPs are the telegram requests coming from?

i can't figured out, but now my bot is working on the free and on the paid account. have you done smth?

curl {"ok":true,"result":{"url":"","has_custom_certificate":false,"pending_update_count":0,"max_connections":40,"ip_address":"XXXXX"}

No, we did not change anything.

after 2 working weeks, i've received this error again:

has_custom_certificate":false,"pending_update_count":4,"last_error_dat e":1669878021,"last_error_message":"Connection timed out","max_connections":40

this is absolute mysticism

Have you tried using a custom domain on your paid account? We're wondering whether telegram could be queueing requests for all PythonAnywhere subdomains together.

yes, i've tried, but it also doesn't work and I have disabled my subscription (because of that). My bot is still not working

Is there any way to find out from Telegram what IP addresses it is using to send the requests?

Unfortunately, I have the same issue. Few days my bot worked correctly, then pythonanywhere stops receiving updates from Telegram. Error log is empty but there are no corresponding (to the post requests that telegram sends) records in access log. Is there any solution? Here is what information I get if receive getWebhookInfo: Info

Thanks for any help

Unfortunately I think that all we can recommend here is that you get in touch with Telegram tech support, if that's at all possible. If nothing is appearing in the access logs for your site, it means that they're just not sending the messages, and only they will know why that is.

Hi Guys!

Same with me. From the access log, I don't see Telegram sending the POST to PythonAnywhere:


{'url': 'XXX, 'has_custom_certificate': False, 'pending_update_count': 5, 'last_error_date': 1674624788, 'last_error_message': 'Connection timed out', 'max_connections': 40, 'ip_address': ''}



{'url': 'XXX', 'has_custom_certificate': False, 'pending_update_count': 6, 'last_error_date': 1674625033, 'last_error_message': 'Connection timed out', 'max_connections': 40, 'ip_address': ''}



{'url': 'XXX', 'has_custom_certificate': False, 'pending_update_count': 6, 'last_error_date': 1674625064, 'last_error_message': 'Connection timed out', 'max_connections': 40, 'ip_address': ''}

If there's nothing in the access log, Telegram is probably not sending those messages for some reason. You could check with their support, as Giles suggested above.

Did anyone manage to solve this issue or was able to get in touch with the Telegram support?

I have the same problem with my Telegram bot which didn't receive any updates since a week ago. I did not make any recent changes to the code and a second bot running on the same Pythonanywhere account with almost the same code is still working fine.

According to the access log I received the last update from Telegram on January 28th from the IP The second bot (the one that is still working) receives his updates from the IP

If I manually call the getWebhookInfo endpoint from the Telegram bot API I get the same as the thread opener (Connection timed out).

I already tried the following without success:

  • deleting the webhook and setting it again (deleteWebhook and setWebhook)
  • temporarily changing the URL
  • revoking the API key

Since a few days my bot is receiving updates from Telegram on the webhook, so everything is working fine again. I wrote to the support a while ago but didn't get any reply, so I don't know if they fixed something manually or if the problem resolved "by itself".

Thanks for sharing that with us!

It's happening again.

Looks like you need to talk to ask telegram.

Hi, i have the same problem . Three weeks ago it began to recieve updates again but it's been two days that i face the same problem & i've tried to contact telegram but they didn't reply. i think there is a serious problem between pythonanywhere servers & Telegram. i'm afraid there is nothing that we users can do about this problem so HELP needed from pythonanywhere staff. Thanks in advance.

It does not look alike anything we can do about it. We do not block it.

The problem happened to me again too. Since a few days, my bot is not receiving updates anymore. What is interesting is that it is again the same instance as last time. My second bot running as a second web app on Pythonanywhere is still working fine.

If telegram is not sending the request, then there is not really anything we can do to help.

@glenn I fully understand that, but I think it is still very helpful to share this kind of issues with other users. I was glad to find this post because it meant that I was not the only one with this issue and it made it less likely that the problem was in my code :)

Since one or two days I'm receiving updates again, so let's hope that it's now working again for good.

The problem happened to me too! Wow, glad to know I'm not the only one. I have been working on the problem for hours. The only thing stange to me was that if I created a compeletly new bot and used it's token then everything worked fine. But, when I reverted back to my usual bot token (even after revoking the token) I got the 'Connection timed out' error.

Looks like the problem is on telegram side of things.

Same problem here... The only weird thing i see is that the last access logs are GET methods from pythonanywhere (probably).

After that, nothing. Telegram webhook info says connection timedout - - [05/May/2023:08:55:35 +0000] "GET / HTTP/1.1" 404 233 "-" "python-requests/2.28.1" "" response-time=0.652 - - [05/May/2023:08:57:39 +0000] "GET / HTTP/1.1" 404 233 "-" "python-requests/2.28.1" "" response-time=0.013 - - [05/May/2023:09:02:32 +0000] "GET / HTTP/1.1" 404 233 "-" "python-requests/2.28.1" "" response-time=0.021 - - [05/May/2023:09:07:26 +0000] "GET / HTTP/1.1" 404 233 "-" "python-requests/2.28.1" "" response-time=0.056

Are you using a custom domain, or a PythonAnywhere subdomain? One theory we have at this point is that a bug on Telegram's side makes them think that all subdomains of are actually the same site, so if there is a problem with one they incorrectly say that all of them are timing out.

I did not change anything, and the bot just suddenly works again 2 days after it originally stopped working

Yeah sound like something out of our control. Glad it's working now though

I have your problem right now)

As mentioned above, our best guess right now is that Telegram have a bug where they treat all sites with hostnames like as if they were the same, so if one times out due to a bug, they will stop delivering messages to all of them. Unfortunately there's nothing we can do about that; you'd need to raise it with Telegram.

Hello! I'm having the same issue with multiple bots. And what's the most interesting, is that it's very unpredictable - it stops working, then it starts working again after a random period of time without any changes, and then stops again. Maybe someone have found some workarounds?

I think there are 2 solutions: 1. Make long polling bot and start it from console for that period of time 2. Chose another hosting provider

I came across this forum post, because I'm currently having the exact same issue with my Telegram bot. I'm not hosting on Pythonanywhere, though, but am using my own VPS. Everything was working fine for years, but recently I got these unpredictable timeouts. Switched to long-polling temporarily, but would like to use webhooks again in the long run. Any ideas what might be causing this?

I have the same issue: did you find a solution or a workaround?

No way, I've deployed my bot on another hosting. I'm using vps now and it works one month without any problem)

For me, the issue seems to have fixed itself in the meanwhile. I switched backed from polling to webhooks and it works fine again.

I still have this issue on one of my two bots hosted on pythonanywhere. Sometimes it works for a few days, but most of the time it doesn't. I'm using a custom domain and each bot is set up on an individual subdomain.

@glenn you asked the IP of telegram: according to the official guide are the subnets and

Every endpoint must:

  • Supports IPv4, IPv6 is currently not supported for webhooks.
  • Accepts incoming POSTs from subnets and on port 443, 80, 88, or 8443.
  • Is able to handle TLS1.2(+) HTTPS-traffic.
  • Provides a supported, verified or self-signed certificate.
  • Uses a CN or SAN that matches the domain you’ve supplied on setup.
  • Supplies all intermediate certificates to complete a verification chain.

Is there something that pythonanywhere do not support or something that requires me to configure something?

That all looks fine.

I think the workaround will be like @blubtest said, to use a custom domain for your bot. That way timeouts on other peoples bots don't affect your own

That all looks fine.

I think the workaround will be like @blubtest said, to use a custom domain for your bot. That way timeouts on other peoples bots don't affect your own

That all looks fine.

I think the workaround will be like @blubtest said, to use a custom domain for your bot. That way timeouts on other peoples bots don't affect your own

I have the same error, I realized that it doesn't happen with some bots, I finalize the ones I create if it gives me the error, because I had one created a while ago and with that one it didn't give me the error, I don't think it's a pythonanywhere problem because with the touch of the old bot it worked without modifying any code, just the token.

That's interesting! There may be a number of different issues that are causing the same symptoms, then.

I think the workaround will be like @blubtest said, to use a custom domain for your bot. That way timeouts on other peoples bots don't affect your own

Unfortunately that's not a workaround because I do have the problem with my custom domain. But it's only one bot out of two, so the problems looks pretty random to me :(

Maybe the domain thing is a red herring, then, and the problem is just that Telegram are randomly stopping supporting specific bots. Have you tried updating the token? If I'm reading @IsmelMago's post correctly, it worked for them.

I am pretty sure I have tried to change the token when my bot stopped working and it did not work

Have you tried to ask telegram about it?

Hola encontré esto : "Para garantizar que podamos hacer eso, existen algunos requisitos básicos: La versión corta Necesitará un servidor que: Admite IPv4; actualmente, IPv6 no es compatible con webhooks. Acepta POST entrantes de subredes el puerto 443, 80, 88 u 8443. Es capaz de manejar tráfico HTTPS TLS1.2(+). Proporciona un certificado respaldado, verificado o autofirmado. Utiliza un CN o SAN que coincide con el dominio que proporcionó en la configuración. Proporciona todos los certificados intermedios para completar una cadena de verificación. Eso es casi todo lo que hay que hacer. Si decide limitar el tráfico a nuestro rango específico de direcciones, esté atento a este documento siempre que tenga problemas. Nuestro rango de IP podría cambiar en el futuro."

eh notado que a cada bot le llegan solicitudes desde distintas subredes, ya que algunos bots funcionan y otros no, probablemente pythonanywhere este limitado a un rango especifico de Ip, en mi caso tengo 4 bots y uno dejo de funcionar, la solución no es cambiar de token, probe con crear otro bot y este por apuntar desde otro ip distinta me llegaban las solicitudes. creo que access.log por alguna razón no esta registrando las solicitudes de aquellas ip no permitidas.

la razón por la cual los bots cambian su estado de funcionamiento cada determinado tiempo es porque telegram cambian el ip predeterminado en un bot para las solicitudes.

Some IPs from that range were blocked. We unblocked them.


Si alguna persona continua con el problema y es de suma importancia que le bot este trabajando les recomiendo que creen una tarea siempre activa temporalmente, dirigiendo las peticiones usando requests.

from telegram.ext import Updater, MessageHandler, Filters import requests

msj_error = "En estos momentos estamos teniendo dificultades en el servidor, porfavor espere un momento e intentelo nuavemente"

def echo(update, context): id_, msj =, update.message.text.strip() url = 'https://su nombre de webhook temporal/' #en este ejemplo estoy pasando solo el id y el mensaje, modifiquen conforme a sus necesidades response =, data={'id_': id_, 'msj': msj}) resp = response.json() if resp['ok']:['msj']) else:, msj_error)

updater = Updater(token='Su_Token_Aqui', use_context=True) dispatcher = updater.dispatcher dispatcher.add_handler(MessageHandler(Filters.text, echo)) updater.start_polling()