I have deployed in pythonanywhere an application that consists of a telegram bot that connects to api.scryfall.com through scrython, a api wrapper (which uses asyncio and aiohttp). The app works perfectly on my computer but when I try to use it from pythonanywhere I get the following error:
Traceback (most recent call last):
File "/home/rayolaser/.local/lib/python3.9/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection
sock = await self._connect_sock(
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock
await self.sock_connect(sock, address)
raise client_error(req.connection_key, exc) from exc
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect
return await fut
File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 507, in _sock_connect
sock.connect(address)
OSError: [Errno 101] Network is unreachable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/rayolaser/.local/lib/python3.9/site-packages/scrython/cards/named.py", line 57, in __init__
super(Named, self).__init__(self.url)
File "/home/rayolaser/.local/lib/python3.9/site-packages/scrython/foundation.py", line 36, in __init__
loop.run_until_complete(main(loop))
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/rayolaser/.local/lib/python3.9/site-packages/scrython/foundation.py", line 32, in main
self.scryfallJson = await getRequest(client, self._url)
File "/home/rayolaser/.local/lib/python3.9/site-packages/scrython/foundation.py", line 27, in getRequest
async with client.get(url, **kwargs) as response:
File "/home/rayolaser/.local/lib/python3.9/site-packages/aiohttp/client.py", line 1138, in __aenter__
self._resp = await self._chorus
File "/home/rayolaser/.local/lib/python3.9/site-packages/aiohttp/client.py", line 535, in _request
conn = await self._connector.connect(
File "/home/rayolaser/.local/lib/python3.9/site-packages/aiohttp/connector.py", line 542, in connect
proto = await self._create_connection(req, traces, timeout)
File "/home/rayolaser/.local/lib/python3.9/site-packages/aiohttp/connector.py", line 907, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/home/rayolaser/.local/lib/python3.9/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
raise last_exc
File "/home/rayolaser/.local/lib/python3.9/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/home/rayolaser/.local/lib/python3.9/site-packages/aiohttp/connector.py", line 992, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.scryfall.com:443 ssl:default [Network is unreachable]