Why can’t Telegram call my webhook script?
Hello. I have a PHP bot hosted on REG.RU hosting. It previously worked correctly, but suddenly stopped receiving webhook requests from Telegram. The hosting support refuses to solve the problem, suggesting instead that I switch to a virtual dedicated server (VDS).
A similar situation has already occurred with another bot on this same hosting. After contacting technical specialists, they resolved the issue but didn’t explain the cause of the malfunction. All protective mechanisms and antivirus programming have been disabled.
Please advise what the problem might be and how to solve it?
Common Issues with Non-Working Telegram Webhooks on REG.RU Hosting
The issue with non-working Telegram webhooks on REG.RU hosting is a fairly common problem. The main reason is usually related to SSL certificates, timeouts, or request blocking at the hosting level. Telegram requires an HTTPS address for webhooks, and many problems arise specifically from incorrect SSL configuration or certificate expiration.
Contents
- Main causes of non-working webhooks
- Step-by-step problem diagnosis
- SSL certificate problem solutions
- Configuration on the REG.RU side
- Alternative solution options
Main causes of non-working webhooks
The problem can be caused by several factors:
1. SSL certificate issues
- Telegram requires mandatory use of HTTPS for webhooks
- Certificate has expired
- Certificate does not meet security requirements
- Self-signed certificates are not accepted by Telegram
2. Timeouts on shared hosting
- REG.RU may limit script execution time
- Firewall blocks incoming requests
- Server load causes delays
3. Incorrect webhook configuration
- Incorrect URL in bot settings
- Missing required headers in the response
- Server routing issues
Important: According to the official Telegram Bot API documentation, the webhook must be accessible via HTTPS. If you’re using HTTP, Telegram will reject the request.
Step-by-step problem diagnosis
Step 1: Check the SSL certificate
Open your webhook URL in a browser and check:
- Are there any security warnings
- Does the site work without errors
- Is the certificate valid
# Check SSL certificate from command line
openssl s_client -connect your-domain.ru:443 -servername your-domain.ru
Step 2: Test webhook accessibility
Create a test script to check accessibility:
<?php
header('Content-Type: application/json');
echo json_encode(['ok' => true, 'result' => true, 'description' => 'Webhook test']);
?>
Step 3: Check hosting logs
Check access logs for requests from Telegram:
- Look for entries with Telegram IP addresses (149.154.160.0/20)
- Pay attention to response codes (200, 404, 503, etc.)
SSL certificate problem solutions
Option 1: Using Let’s Encrypt
A free and reliable option:
# Install Certbot
sudo apt-get install certbot python3-certbot-apache
# Get certificate
sudo certbot --apache -d your-domain.ru
Option 2: Configuration through REG.RU panel
- Go to the hosting control panel
- Navigate to the “Domain Management” section
- Configure the SSL certificate
- Verify that port 443 redirects to your script
Option 3: Using Cloudflare
As Mozilla Developer Network explains, Cloudflare provides free SSL and speeds up performance:
- Connect your domain to Cloudflare
- Enable “Full (strict)” mode
- Configure HTTPS proxying
Configuration on the REG.RU side
.htaccess configuration
Add to the .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
<IfModule mod_php7.c>
php_value max_execution_time 60
php_value max_input_time 60
php_value memory_limit 256M
</IfModule>
Check access permissions
Ensure the web server has access to the script:
# Check permissions
ls -la /path/to/your/webhook.php
# Should be -rw-r--r--
Firewall configuration
Verify that Telegram IP addresses are not blocked:
# Allow Telegram IP addresses
iptables -I INPUT -s 149.154.160.0/20 -j ACCEPT
iptables -I INPUT -s 91.108.4.0/22 -j ACCEPT
iptables -I INPUT -s 91.108.12.0/22 -j ACCEPT
iptables -I INPUT -s 91.108.56.0/22 -j ACCEPT
Alternative solution options
Option 1: Using ngrok for testing
For quick verification, you can use ngrok:
# Install and run ngrok
./ngrok http 80
In the bot settings, use a URL like https://your-ngrok-id.ngrok.io/webhook.php
Option 2: Moving to a cloud solution
According to the official Telegram documentation, cloud services provide better stability:
- DigitalOcean
- AWS Lightsail
- Google Cloud Platform
Option 3: Using Telegram Mini Apps
As Telegram Mini Apps documentation explains, you can use built-in applications to bypass hosting limitations.
Conclusion
The main problems with webhooks on REG.RU are usually related to:
- SSL certificates - the most common cause
- Execution timeouts - shared hosting has limitations
- Firewalls and blocking - especially for new IP addresses
Recommended actions:
- First, check the SSL certificate
- Check logs for requests from Telegram
- Configure the correct response headers
- If the problem persists, consider moving to a VDS
For a temporary solution, you can use ngrok or cloud services. In the long term, moving to a VDS can actually solve most performance and availability issues.