Forums

error when trying to use the proxy for the telegram bot

I'm trying to use a proxy for a telegram:

proxy_auth = aiohttp.BasicAuth("login", "password")
PROXY_URL = "http://login:password@46.8.202.42:7956"
logging.basicConfig(level=logging.INFO)


bot = Bot(token=api_reshebnik_bot, proxy=PROXY_URL)
dp = Dispatcher(bot)

but I get an error:

Traceback (most recent call last):
File "/home/Internet1Soft/telegram bots/reshebnik_bot/main_bot.py", line 36, in <module>
executor.start_polling(dp)
File "/home/Internet1Soft/.local/lib/python3.9/site-packages/aiogram/utils/executor.py", line 45, in start_polling
executor.start_polling(
File "/home/Internet1Soft/.local/lib/python3.9/site-packages/aiogram/utils/executor.py", line 320, in start_polling
loop.run_until_complete(self._startup_polling())
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/Internet1Soft/.local/lib/python3.9/site-packages/aiogram/utils/executor.py", line 372, in _startup_polling
await self._welcome()
File "/home/Internet1Soft/.local/lib/python3.9/site-packages/aiogram/utils/executor.py", line 361, in _welcome
user = await self.dispatcher.bot.me
File "/home/Internet1Soft/.local/lib/python3.9/site-packages/aiogram/bot/bot.py", line 30, in me
setattr(self, '_me', await self.get_me())
File "/home/Internet1Soft/.local/lib/python3.9/site-packages/aiogram/bot/bot.py", line 233, in get_me
result = await self.request(api.Methods.GET_ME, payload)
File "/home/Internet1Soft/.local/lib/python3.9/site-packages/aiogram/bot/base.py", line 236, in request
return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
File "/home/Internet1Soft/.local/lib/python3.9/site-packages/aiogram/bot/api.py", line 142, in make_request
raise exceptions.NetworkError(f"aiohttp client throws an error: {e.__class__.__name__}: {e}")
aiogram.utils.exceptions.NetworkError: Aiohttp client throws an error: ClientProxyConnectionError: Cannot connect to host 46.8.202.42:7956 ssl:default [Connect call failed ('46.8.202.42', 7956)]

Free accounts can only connect to domains in our allow list. You will not be able to connect to a random IP address from a free account.