diff --git a/src/aleph/vm/orchestrator/views/host_status.py b/src/aleph/vm/orchestrator/views/host_status.py index 6ef41c0ee..5ab80bebc 100644 --- a/src/aleph/vm/orchestrator/views/host_status.py +++ b/src/aleph/vm/orchestrator/views/host_status.py @@ -23,11 +23,14 @@ async def wrapper(*args: Any, **kwargs: Any) -> bool: async def check_ip_connectivity(url: str, socket_family: socket.AddressFamily = socket.AF_UNSPEC) -> bool: timeout = aiohttp.ClientTimeout(total=5) async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(family=socket_family), timeout=timeout) as session: - async with session.get(url) as resp: - # We expect the Quad9 endpoints to return a 404 error, but other endpoints may return a 200 - if resp.status not in (200, 404): - resp.raise_for_status() - return True + try: + async with session.get(url) as resp: + # We expect the Quad9 endpoints to return a 404 error, but other endpoints may return a 200 + if resp.status not in (200, 404): + resp.raise_for_status() + return True + except aiohttp.ClientConnectorError: + return False @return_false_on_timeout