home-assistant/core · error · UpdateFailed

cannot_connect

Error message

cannot_connect

What it means

UpdateFailed error (translation key 'cannot_connect') raised by the APCUPSd DataUpdateCoordinator when fetching status from the NUT/apcupsd daemon fails at the transport layer. It wraps OSError (connection refused, DNS failure, unreachable host) and asyncio.IncompleteReadError from aioapcaccess.request_status, and also fires when the overall asyncio.timeout(CONNECTION_TIMEOUT) elapses. It tells HA the coordinator could not reach the UPS daemon so the entry stays in a retry/reconnect state.

Source

Thrown at homeassistant/components/apcupsd/coordinator.py:121

            name=self.data.name or "APC UPS",
            hw_version=self.data.get("FIRMWARE"),
            sw_version=self.data.get("VERSION"),
            serial_number=self.data.serial_no,
        )

    @override
    async def _async_update_data(self) -> APCUPSdData:
        """Fetch the latest status from APCUPSd.

        Note that the result dict uses upper case for each resource, where our
        integration uses lower cases as keys internally.
        """
        async with asyncio.timeout(CONNECTION_TIMEOUT):
            try:
                data = await aioapcaccess.request_status(self._host, self._port)
                return APCUPSdData(data)
            except (OSError, asyncio.IncompleteReadError) as error:
                raise UpdateFailed(
                    translation_domain=DOMAIN,
                    translation_key="cannot_connect",
                ) from error

View on GitHub (pinned to 58a3fdb3ea)

Solutions

  1. Verify apcupsd is running and listening: 'systemctl status apcupsd' and 'ss -tlnp | grep 3551' on the UPS host
  2. Confirm the host and port in the config entry match the daemon's NISPORT (default 3551)
  3. Test reachability from the HA host: 'nc <host> 3551' or 'telnet <host> 3551'
  4. Open the port in the firewall / fix SELinux rules, then reload the integration to trigger a retry
Defensive patterns

Strategy: retry

Validate before calling

# From the HA host, check the NIS port before relying on the integration
# nc -z -w3 <ups_host> 3551 && echo ok

Prevention

When it happens

Trigger: aioapcaccess.request_status(host, port) raising ConnectionRefusedError/OSError (daemon down, wrong host/port, firewall), or the TCP connection opening but the response never completing (IncompleteReadError), or no response within CONNECTION_TIMEOUT seconds.

Common situations: apcupsd service not running on the target host; NIS port (default 3551) wrong or blocked by firewall; appliance/NAS rebooted; host configured by IP that changed via DHCP; SELinux blocking the connection.

Related errors


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