Telegram Bot with WebHook Fails

I intend to set up my Telegram bot with webhook. I have configured everything according to instructions I have found from valid sources.

However, Bot is not receiving webhook updates and I get below error when I send “getWebhookInfo” request to Telegram API.

{"ok":true,"result":{"url":"","has_custom_certificate":true,"pending_update_count":4,"last_error_date":1585773597,"last_error_message":"Connection timed out","max_connections":40}}

Here is the configuration I have done for the droplet on Digitalocean.

  • Created a self-signed key and certificate pair with OpenSSL and put them in /etc/ssl/private/ and /etc/ssl/certs/

  • The firewall was adjusted and below is the FW status:

To                         Action      From
--                         ------      ----
Nginx HTTP                 ALLOW       Anywhere
22/tcp                     ALLOW       Anywhere
OpenSSH                    ALLOW       Anywhere
Nginx HTTP (v6)            ALLOW       Anywhere (v6)
22/tcp (v6)                ALLOW       Anywhere (v6)
OpenSSH (v6)               ALLOW       Anywhere (v6)
server {
    listen              443 ssl;
    server_name         SERVER_IP_ADDRESS;
    ssl_certificate     bot.pem;
    ssl_certificate_key private.key;

    location /TOKEN1 {

    location /TOKEN2 {
  • Tested Nginx configurations and restart the webserver by executing sudo nginx -t && sudo systemctl restart nginx and getting the below output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

In my application file which is running on the server, the python script is as follows to get updates from Telegram :

updater.start_webhook(listen='', port=5000, url_path='TokenID')'https://<DropletID>/TokenId',
                        certificate=open('bot.pem', 'rb'))

Am I missing something somewhere? Any idea what could be the cause of the problem? Any help is very much appreciated. Thanks.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I think you need to open the HTTPS port (443) to be available to listen to it.

try with: sudo ufw allow https