I
I
Ivan Tuinov2020-02-02 22:11:03
Python
Ivan Tuinov, 2020-02-02 22:11:03

TelegramBotAPI Python gives an error, what should I do?

import telebot


bot = telebot.TeleBot('910600423:AAGretCvuR1BoHB5srtYTPy5ovQJjzWtpCM')


@bot.message_handler(commands=['start'])
def sendmessage(message):
    bot.send_message(message.chat.id, 'Тест1')

bot.polling(none_stop=True)
Throws error on startup
2020-02-02 21:59:51,819 (util.py:66 PollingThread) ERROR - TeleBot: "ConnectionError occurred, args=(MaxRetryError("HTTPSConnectionPool(host='api.telegram.org', port= 443): Max retries exceeded with url: /bot910600423:AAGretCvuR1BoHB5srtYTPy5ovQJjzWtpCM/getUpdates?offset=1&timeout=20 (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10061] Connection failed because destination computer rejected connection request'))")),)
Traceback (most recent call last):
File "C:\Users\Van4uha\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py ", line 156, in _new_conn
conn = connection.create_connection(
File "C:\Users\Van4uha\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\connection.py", line 84, in create_connection
raise err
File "C:\Users\ Van4uha\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\connection.py", line 74, in create_connection
sock.connect(sa)
ConnectionRefusedError: [WinError 10061] Connection not established, because destination computer denied connection request

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Van4uha\AppData\Local\Programs\Python\Python38-32\lib\site- packages\urllib3\connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "C:\Users\Van4uha\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 376, in _make_request
self._validate_conn(conn)
File "C:\ Users\Van4uha\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 994, in _validate_conn
conn.connect()
File "C:\Users\Van4uha\AppData\ Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 300, in connect
conn = self._new_conn()
File "C:\Users\Van4uha\AppData\Local\Programs\ Python\Python38-32\lib\site-packages\urllib3\connection.py", line 168, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [WinError 10061] the destination computer rejected the connection request

Then there are even more errors, but they do not fit, if necessary, I can send in full

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Q
Qvint01, 2020-02-02
@vanoe37

Just put it on pythonanywhere and you won't need to start vpn every time.

D
Dikower, 2020-02-02
@Dikower

Use a proxy, data about which can be passed in the parameters during initialization, or there is a method through ngrok

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question