home-assistant/core · error · InputValidationError

cannot_connect

cannot_connect

Error message

cannot_connect

What it means

Raised during the Bond integration config flow when validating user input (host + access token). The flow builds a Bond API client, calls BondHub.setup(max_devices=1), and translates aiohttp's ClientConnectionError into InputValidationError('cannot_connect'). It means the HTTP transport to the Bond hub failed before any response was read: DNS failure, connection refused, timeout, or SSL handshake breakdown.

Source

Thrown at homeassistant/components/bond/config_flow.py:60

    with contextlib.suppress(ClientConnectionError):
        response = await bond.token()
    return response.get("token")


async def _validate_input(hass: HomeAssistant, data: dict[str, Any]) -> tuple[str, str]:
    """Validate the user input allows us to connect."""

    bond = Bond(
        data[CONF_HOST],
        data[CONF_ACCESS_TOKEN],
        session=async_get_clientsession(hass),
        requestor_uuid=RequestorUUID.HOME_ASSISTANT,
    )
    try:
        hub = BondHub(bond, data[CONF_HOST])
        await hub.setup(max_devices=1)
    except ClientConnectionError as error:
        raise InputValidationError("cannot_connect") from error
    except ClientResponseError as error:
        if error.status == HTTPStatus.UNAUTHORIZED:
            raise InputValidationError("invalid_auth") from error
        raise InputValidationError("unknown") from error
    except Exception as error:
        _LOGGER.exception("Unexpected exception")
        raise InputValidationError("unknown") from error

    # Return unique ID from the hub to be stored in the config entry.
    if not hub.bond_id:
        raise InputValidationError("old_firmware")

    return hub.bond_id, hub.name


class BondConfigFlow(ConfigFlow, domain=DOMAIN):
    """Handle a config flow for Bond."""

View on GitHub (pinned to 58a3fdb3ea)

Solutions

  1. Verify the host reachable: ping the Bond hub IP or open http://<host>:30001/v2/devices in a browser.
  2. Fix or re-discover the host address (re-run discovery in the config flow) and resubmit.
  3. Check firewall/VLAN rules allow the Home Assistant host to reach the Bond hub on its local API port.
  4. If the hub was rebooting, wait ~30s and retry the config step.
Defensive patterns

Strategy: validation

Validate before calling

import asyncio, socket

async def bond_host_reachable(host: str, port: int = 30001, timeout: float = 3.0) -> bool:
    try:
        _, w = await asyncio.wait_for(asyncio.open_connection(host, port), timeout)
        w.close()
        return True
    except (OSError, asyncio.TimeoutError):
        return False

Try / catch

try:
    await validate_input(hass, data)
except InputValidationError as err:
    if err.error_status == "cannot_connect":  # show host unreachable message
        ...

Prevention

When it happens

Trigger: Calling async_step_user / async_step_discovery_confirmation with a CONF_HOST that is unreachable, a wrong IP after the hub changed address, the Bond hub being powered off, or a firewall dropping TCP 30001 (Bond local API). BondHub.setup() performs the initial HTTP request(s); any ClientConnectionError from it maps here.

Common situations: Hub moved to a new DHCP IP, mDNS-discovered address stale, VLAN/IoT network segmentation blocking the client, hub firmware rebooting mid-request.

Related errors


AI-assisted analysis of home-assistant/core@58a3fdb3ea (2026-08-14). Data as JSON: /api/errors/c3c126464d31e158. Report an issue: GitHub.