P
P
Python Newbie2021-08-20 11:10:25
Python
Python Newbie, 2021-08-20 11:10:25

pythonanywhere doesn't work. What to do?

I'm running a telegram bot on pythonanywhere and it throws an error:

18:20 ~ $ python t2bot.py
WARNING:aiogram:Goodbye!
Traceback (most recent call last):
  File "/home/levman/.local/lib/python3.9/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "uvloop/loop.pyx", line 2024, in create_connection
  File "uvloop/loop.pyx", line 2000, in uvloop.loop.Loop.create_connection
  File "uvloop/handles/tcp.pyx", line 182, in uvloop.loop.TCPTransport.connect
  File "uvloop/handles/tcp.pyx", line 204, in uvloop.loop._TCPConnectRequest.connect
OSError: [Errno 101] Network is unreachable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/levman/.local/lib/python3.9/site-packages/aiogram/bot/api.py", line 139, in make_request
    async with session.post(url, data=req, **kwargs) as response:
  File "/home/levman/.local/lib/python3.9/site-packages/aiohttp/client.py", line 1117, in __aenter__
    self._resp = await self._coro
  File "/home/levman/.local/lib/python3.9/site-packages/aiohttp/client.py", line 520, in _request
    conn = await self._connector.connect(
  File "/home/levman/.local/lib/python3.9/site-packages/aiohttp/connector.py", line 535, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/home/levman/.local/lib/python3.9/site-packages/aiohttp/connector.py", line 892, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/home/levman/.local/lib/python3.9/site-packages/aiohttp/connector.py", line 1051, in _create_direct_connection
    raise last_exc
  File "/home/levman/.local/lib/python3.9/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/home/levman/.local/lib/python3.9/site-packages/aiohttp/connector.py", line 975, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.telegram.org:443 ssl:default [Network is unreachable]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/levman/t2bot.py", line 123, in <module>
    executor.start_polling(dp, skip_updates=True)
  File "/home/levman/.local/lib/python3.9/site-packages/aiogram/utils/executor.py", line 45, in start_polling
    executor.start_polling(
  File "/home/levman/.local/lib/python3.9/site-packages/aiogram/utils/executor.py", line 320, in start_polling
    loop.run_until_complete(self._startup_polling())
  File "uvloop/loop.pyx", line 1501, in uvloop.loop.Loop.run_until_complete
  File "/home/levman/.local/lib/python3.9/site-packages/aiogram/utils/executor.py", line 371, in _startup_polling
    await self._welcome()
  File "/home/levman/.local/lib/python3.9/site-packages/aiogram/utils/executor.py", line 361, in _welcome
    user = await self.dispatcher.bot.me
  File "/home/levman/.local/lib/python3.9/site-packages/aiogram/bot/bot.py", line 29, in me
    setattr(self, '_me', await self.get_me())
  File "/home/levman/.local/lib/python3.9/site-packages/aiogram/bot/bot.py", line 215, in get_me
    result = await self.request(api.Methods.GET_ME, payload)
  File "/home/levman/.local/lib/python3.9/site-packages/aiogram/bot/base.py", line 208, in request
    return await api.make_request(self.session, self.server, self.__token, method, data, files,
  File "/home/levman/.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: ClientConnectorError: Cannot connect to host api.telegram.org:443 ssl:default
 [Network is unreachable]


And everything worked locally.
Where is the mistake?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
soremix, 2021-08-20
@SoreMix

https://qna.habr.com/search?q=Cannot+connect+to+ho...
100500 replies

D
Denys Plakhtii, 2021-08-20
@DenysPlakhtiy

Most likely you have a free version of hosting, and it has limitations.
Source: https://www.pythonanywhere.com/forums/topic/28845/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question