home-assistant/core · error · ConfigEntryNotReady

cannot_connect

cannot_connect

Error message

An error occurred while connecting to the {device} printer: {error}

What it means

ConfigEntryNotReady with translation_key 'cannot_connect', raised during integration setup when Brother.create() fails with ConnectionError, SnmpError, or TimeoutError. SNMP is used to query the printer, so these mean the printer did not answer SNMP GET requests on the configured host/port/community. HA will retry setup in the background.

Source

Thrown at homeassistant/components/brother/__init__.py:39

_LOGGER = logging.getLogger(__name__)

PLATFORMS = [Platform.SENSOR]


async def async_setup_entry(hass: HomeAssistant, entry: BrotherConfigEntry) -> bool:
    """Set up Brother from a config entry."""
    host = entry.data[CONF_HOST]
    port = entry.data[SECTION_ADVANCED_SETTINGS][CONF_PORT]
    community = entry.data[SECTION_ADVANCED_SETTINGS][CONF_COMMUNITY]
    printer_type = entry.data[CONF_TYPE]

    snmp_engine = await async_get_snmp_engine(hass)
    try:
        brother = await Brother.create(
            host, port, community, printer_type=printer_type, snmp_engine=snmp_engine
        )
    except (ConnectionError, SnmpError, TimeoutError) as error:
        raise ConfigEntryNotReady(
            translation_domain=DOMAIN,
            translation_key="cannot_connect",
            translation_placeholders={
                "device": entry.title,
                "error": repr(error),
            },
        ) from error

    coordinator = BrotherDataUpdateCoordinator(hass, entry, brother)
    await coordinator.async_config_entry_first_refresh()

    if brother.serial.lower() != entry.unique_id:
        raise ConfigEntryError(
            translation_domain=DOMAIN,
            translation_key="serial_mismatch",
            translation_placeholders={
                "device": entry.title,
            },

View on GitHub (pinned to 58a3fdb3ea)

Solutions

  1. Verify the printer is awake and reachable: ping the host, then test SNMP with snmpwalk -v2c -c <community> <host>
  2. Confirm host, port, and SNMP community in the integration's advanced options match the printer's SNMP settings
  3. Open UDP port 161 between Home Assistant and the printer on any firewall
  4. Enable SNMP (v1/v2c) in the printer's web admin if it is disabled
  5. Give HA time — ConfigEntryNotReady retries automatically once connectivity returns

Example fix

# diagnose from the HA host
# before: entry keeps retrying with cannot_connect
snmpwalk -v2c -c public 192.168.1.50 1.3.6.1.2.1.25.1.1.0
# if timeout: fix community/port, then reload the integration
# after: entry sets up and coordinator first refresh succeeds
Defensive patterns

Strategy: retry

Validate before calling

# From the HA host, confirm SNMP answers before (re)loading the entry:
#   snmpwalk -v2c -c <community> <host> 1.3.6.1.2.1.25.1.1.0
# A response means setup will succeed.

Try / catch

# setup is framework-driven; the entry lands in 'setup_retry' on ConfigEntryNotReady
# Monitor state:
state = hass.config_entries.async_get_entry(entry_id).state
if state == ConfigEntryState.SETUP_RETRY:
    # printer not answering SNMP yet; wait or fix network

Prevention

When it happens

Trigger: Wrong host or port in the config entry; wrong SNMP community string (printer drops requests); SNMP disabled on the printer; printer asleep or off; UDP port 161 blocked between HA and the printer.

Common situations: Default community 'public' changed by printer admin; printer energy-saving mode not responding to SNMP; firewall/NAT rules or VLANs blocking UDP 161; printer IP changed after router renewal.

Related errors


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