pythonanywhere Error

Написав дискорд бота на disnake столкнулся с проблемой при попытке запустить его на хостинге pythonanywhere Ошибка:

Traceback (most recent call last):
  File "/home/popa228337123/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1025, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1064, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1049, in create_connection
    sock = await self._connect_sock(
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 960, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 500, in sock_connect
    return await fut
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 535, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('162.159.128.233', 443)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/popa228337123/dsb/bot.py", line 160, in <module>
    bot.run('*токен*')
  File "/home/popa228337123/.local/lib/python3.10/site-packages/disnake/client.py", line 1126, in run
    return future.result()
  File "/home/popa228337123/.local/lib/python3.10/site-packages/disnake/client.py", line 1105, in runner
    await self.start(*args, **kwargs)
  File "/home/popa228337123/.local/lib/python3.10/site-packages/disnake/client.py", line 1066, in start
    await self.login(token)
  File "/home/popa228337123/.local/lib/python3.10/site-packages/disnake/ext/commands/interaction_bot_base.py", line 224, in login
    await super().login(token)
  File "/home/popa228337123/.local/lib/python3.10/site-packages/disnake/ext/commands/common_bot_base.py", line 131, in login
    await super().login(token=token)  # type: ignore
  File "/home/popa228337123/.local/lib/python3.10/site-packages/disnake/client.py", line 865, in login
    data = await self.http.static_login(token.strip())
  File "/home/popa228337123/.local/lib/python3.10/site-packages/disnake/http.py", line 462, in static_login
    data: user.User = await self.request(Route("GET", "/users/@me"))
  File "/home/popa228337123/.local/lib/python3.10/site-packages/disnake/http.py", line 338, in request
    async with self.__session.request(method, url, **kwargs) as response:
  File "/home/popa228337123/.local/lib/python3.10/site-packages/aiohttp/client.py", line 1197, in __aenter__
    self._resp = await self._coro
  File "/home/popa228337123/.local/lib/python3.10/site-packages/aiohttp/client.py", line 581, in _request
    conn = await self._connector.connect(
  File "/home/popa228337123/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/home/popa228337123/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 944, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/home/popa228337123/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1257, in _create_direct_connection
    raise last_exc
  File "/home/popa228337123/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1226, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/home/popa228337123/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1033, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discord.com:443 ssl:default [Connect call failed ('162.159.128.233', 443)]

До этого спокойно запускал на своём ПК и работало БЕЗ ошибок. Может кто-то сказать как это фиксить или кинуть ссылку на другой бесплатный хостинг, который работает без проблем для дискорд ботов?


Ответы (1 шт):

Автор решения: Andrew Hobbit

На бесплатном аккаунте надо использовать прокси:

proxy.server:3128

Прокси фильтрует подключения по "белому списку". Все адреса, к которым разрешены подключения можно посмотреть здесь. Подробности есть в документации.

→ Ссылка