Answer the question
In order to leave comments, you need to log in
Telegram bot gives an error on startup, how to fix it?
raceback (most recent call last):
File "main.py", line 682, in
bot.delete_webhook()
File "D:\Python\lib\site-packages\telebot\__init__.py", line 228, in delete_webhook
return apihelper.delete_webhook(self.token)
File "D:\Python\lib\site-packages\telebot\apihelper.py", line 160, in delete_webhook
return _make_request(token, method_url)
File "D:\Python\lib\site -packages\telebot\apihelper.py", line 54, in _make_request
timeout=(connect_timeout, read_timeout), proxies=proxy)
File "D:\Python\lib\site-packages\requests\sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "D:\Python\lib\site-packages\requests\sessions.py", line 585, in send
r = adapter.send(request, **kwargs)
File "D:\Python\lib\site-packages\requests\adapters.py", line 467, in send
raise ConnectionError(e, request=request)
requests.exceptions. ConnectionError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot297175576:AAFX44Xop-l2tx6uCKKt7HJt2HF2YK-Vek4/deleteWebhook (Caused by NewConnectionError(': Failed to establish a new connection: [ WinError 10061] Connection failed because the destination computer refused the connection request'))
Answer the question
In order to leave comments, you need to log in
I am sure that the problem is in Telegram blocking on the territory of the Russian Federation.
Possible solutions:
If the bot is running on the local machine -> proxy or VPN (I used tor).
If the bot is spinning on a hosting -> rent a foreign hosting.
import telebot
from telebot import apihelper
bot = telebot.TeleBot(TOKEN)
apihelper.proxy = {'https': 'socks5h://user:[email protected]:1080'}
I see that the topic is old, but after a long search, this helped me:
in the telebot library in the apihelper.py file, change the connection
from https://api.telegram.org/file/bot{0}/{1}
to https:// telegg.ru/orig/bot{0}/{1} I
found the solution already in youtube deep under the video in the comments)
I hope it will help someone else!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question