Forums

OSError: [Errno 101] Network is unreachable

Подскажите в чем проблема? - Я заплатил 5$ - но это не решило проблему

14:01 ~/bot $ python main.py
INFO:__main__:GRAB - Запущен
Traceback (most recent call last):
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
  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 505, 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 "/home/GUNS/.local/lib/python3.10/site-packages/aiogram/bot/api.py", line 139, in make_request
    async with session.post(url, data=req, **kwargs) as response:
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/client.py", line 1167, in __aenter__
    self._resp = await self._coro
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/client.py", line 562, in _request
    conn = await self._connector.connect(
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _create_connection
   _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1209, in _create_direct_connection
    raise last_exc
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1178, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 988, 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/GUNS/bot/main.py", line 984, in main
    await send_notification("Бот запущен")
  File "/home/GUNS/bot/main.py", line 102, in send_notification
    await bot.send_message(chat_id, message)
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiogram/bot/bot.py", line 346, in send_message
    result = await self.request(api.Methods.SEND_MESSAGE, payload)
  File "/home/GUNS/.local/lib/python3.10/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/GUNS/.local/lib/python3.10/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:defau
lt [Network is unreachable]

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/GUNS/bot/main.py", line 1003, in main
    await send_notification(f"Произошла ошибка: {str(e)}")
  File "/home/GUNS/.local/lib/python3.10/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:defau
lt [Connect call failed ('149.154.167.220', 443)]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/GUNS/bot/main.py", line 1011, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/GUNS/bot/main.py", line 1007, in main
    await send_notification("Бот остановлен")
  File "/home/GUNS/.local/lib/python3.10/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:defau
lt [Network is unreachable]
14:02 ~/bot $ python main.py
INFO:__main__:GRAB - Запущен
Traceback (most recent call last):
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
  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 505, 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 "/home/GUNS/.local/lib/python3.10/site-packages/aiogram/bot/api.py", line 139, in make_request
    async with session.post(url, data=req, **kwargs) as response:
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/client.py", line 1167, in __aenter__
    self._resp = await self._coro
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/client.py", line 562, in _request
    conn = await self._connector.connect(
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1209, in _create_direct_connection
    raise last_exc
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1178, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 988, 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/GUNS/bot/main.py", line 984, in main
    await send_notification("Бот запущен")
  File "/home/GUNS/bot/main.py", line 102, in send_notification
    await bot.send_message(chat_id, message)
  File "/home/GUNS/.local/lib/python3.10/site-packages/aiogram/bot/bot.py", line 346, in send_message
    result = await self.request(api.Methods.SEND_MESSAGE, payload)
  File "/home/GUNS/.local/lib/python3.10/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/GUNS/.local/lib/python3.10/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:defau
lt [Network is unreachable]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/GUNS/bot/main.py", line 1003, in main
    await send_notification(f"Произошла ошибка: {str(e)}")
  File "/home/GUNS/.local/lib/python3.10/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:defau
lt [Connect call failed ('149.154.167.220', 443)]

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/GUNS/bot/main.py", line 1011, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/GUNS/bot/main.py", line 1007, in main
    await send_notification("Бот остановлен")
  File "/home/GUNS/.local/lib/python3.10/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:defau
lt [Network is unreachable]
14:19 ~/bot $

I solved the problem. Topic closed

Great, glad to hear you solved it!