Answer the question
In order to leave comments, you need to log in
How to fix error 10061 when connecting a telegram bot to a proxy?
Hello, I'm trying to connect a bot to a proxy to bypass the blocking, but it gives an error:
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionRefusedError(10061, 'Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение', None, 10061, None))
import telebot
from telebot import types, apihelper
apihelper.proxy = {'https:':'socks5://логин:пароль@IP:порт'}
bot = telebot.TeleBot('Верный токен')
bot.polling(none_stop=True)
Answer the question
In order to leave comments, you need to log in
Updated requests, urllib3, gunicorn, PySocks Instead
of :socks5
socks5h
telebot.apihelper.proxy = {'https':'socks5h://127.0.0.1:9050'}
Install pysocks: pip install pysocks
Socks5 only work if pysocks is installed. A common problem, I myself encountered it when users ran the script and complained that it did not work with proxies.
=)
UPD: Maybe there are other libraries that work with socks5 and without additional packages, but it is for requests proxy that you need to install pysocks.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question