core: Failed to initialize c-ares channel

The problem

I’m seeing this issue on multiple integrations: Sonos, Forecast Solar (#144453), Tronity, TeamTracker, SmartThings, and Unifi.

They cannot be setup as a result of this.

What version of Home Assistant Core has the issue?

core-2025.5.0

What was the last working version of Home Assistant Core?

core-2025.4.x

What type of installation are you running?

Home Assistant Container

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet


Anything in the logs that might be useful for us?

TeamTracker:
This error originated from a custom integration.

Logger: custom_components.teamtracker
Source: helpers/update_coordinator.py:412
integration: Team Tracker (documentation, issues)
First occurred: 10:11:37 (21 occurrences)
Last logged: 10:11:37

Error fetching team_tracker_golf data: Failed to initialize c-ares channel
Error fetching team_tracker_golf_tiger data: Failed to initialize c-ares channel
Error fetching team_tracker_golf_jt data: Failed to initialize c-ares channel
Error fetching team_tracker_golf_rory data: Failed to initialize c-ares channel
Error fetching team_tracker_golf_spieth data: Failed to initialize c-ares channel

---------------------
Sonos

Logger: homeassistant.config_entries
Source: config_entries.py:749
First occurred: 10:11:42 (1 occurrence)
Last logged: 10:11:42

Error setting up entry Sonos for sonos
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 749, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sonos/__init__.py", line 171, in async_setup_entry
    await manager.setup_platforms_and_discovery()
  File "/usr/src/homeassistant/homeassistant/components/sonos/__init__.py", line 603, in setup_platforms_and_discovery
    await self.async_poll_manual_hosts()
  File "/usr/src/homeassistant/homeassistant/components/sonos/__init__.py", line 461, in async_poll_manual_hosts
    await self._async_handle_discovery_message(
    ...<3 lines>...
    )
  File "/usr/src/homeassistant/homeassistant/components/sonos/__init__.py", line 502, in _async_handle_discovery_message
    await self.async_subscribe_to_zone_updates(discovered_ip)
  File "/usr/src/homeassistant/homeassistant/components/sonos/__init__.py", line 227, in async_subscribe_to_zone_updates
    sub = await soco.zoneGroupTopology.subscribe()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/soco/events_asyncio.py", line 373, in _async_wrap_subscribe
    await self.event_listener.async_start(self.service.soco)
  File "/usr/local/lib/python3.13/site-packages/soco/events_asyncio.py", line 219, in async_start
    self.session = ClientSession(raise_for_status=True, timeout=client_timeout)
                   ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 359, in __init__
    connector = TCPConnector(loop=loop)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 869, in __init__
    resolver = DefaultResolver(loop=self._loop)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/resolver.py", line 96, in __init__
    self._resolver = aiodns.DNSResolver(*args, **kwargs)
                     ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiodns/__init__.py", line 67, in __init__
    self._channel = pycares.Channel(event_thread=True,
                    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
                                    timeout=timeout,
                                    ^^^^^^^^^^^^^^^^
                                    **kwargs)
                                    ^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pycares/__init__.py", line 422, in __init__
    raise AresError('Failed to initialize c-ares channel')
pycares.AresError: Failed to initialize c-ares channel

------------

SmartThings:
Logger: homeassistant
Source: /usr/src/homeassistant/homeassistant/runner.py:112
First occurred: 10:11:46 (1 occurrence)
Last logged: 10:11:46

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/pysmartthings/smartthings.py", line 508, in subscribe
    async with ClientSession(timeout=timeout) as session:
               ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 359, in __init__
    connector = TCPConnector(loop=loop)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 869, in __init__
    resolver = DefaultResolver(loop=self._loop)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/resolver.py", line 96, in __init__
    self._resolver = aiodns.DNSResolver(*args, **kwargs)
                     ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiodns/__init__.py", line 67, in __init__
    self._channel = pycares.Channel(event_thread=True,
                    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
                                    timeout=timeout,
                                    ^^^^^^^^^^^^^^^^
                                    **kwargs)
                                    ^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pycares/__init__.py", line 422, in __init__
    raise AresError('Failed to initialize c-ares channel')
pycares.AresError: Failed to initialize c-ares channel

--------------

Unifi:
Logger: homeassistant
Source: components/unifiprotect/discovery.py:54
First occurred: 10:12:24 (1 occurrence)
Last logged: 10:12:24

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/unifiprotect/discovery.py", line 34, in _async_discovery
    async_trigger_discovery(hass, await async_discover_devices())
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/unifiprotect/discovery.py", line 54, in async_discover_devices
    devices = await scanner.async_scan()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/unifi_discovery/__init__.py", line 521, in async_scan
    await self._probe_services_and_system(response_list)
  File "/usr/local/lib/python3.13/site-packages/unifi_discovery/__init__.py", line 432, in _probe_services_and_system
    connector=TCPConnector(ssl=False), timeout=API_TIMEOUT
              ~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 869, in __init__
    resolver = DefaultResolver(loop=self._loop)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/resolver.py", line 96, in __init__
    self._resolver = aiodns.DNSResolver(*args, **kwargs)
                     ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiodns/__init__.py", line 67, in __init__
    self._channel = pycares.Channel(event_thread=True,
                    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
                                    timeout=timeout,
                                    ^^^^^^^^^^^^^^^^
                                    **kwargs)
                                    ^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pycares/__init__.py", line 422, in __init__
    raise AresError('Failed to initialize c-ares channel')
pycares.AresError: Failed to initialize c-ares channel

---------------

Tronity:
This error originated from a custom integration.

Logger: custom_components.tronity
Source: helpers/update_coordinator.py:380
integration: Tronity (documentation, issues)
First occurred: 10:11:40 (7 occurrences)
Last logged: 10:15:43

Unexpected error fetching tronity data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 380, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 281, in _async_update_data
    return await self.update_method()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tronity/__init__.py", line 62, in async_update_data
    bearer_token = await get_bearer_token(client_id, client_secret)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tronity/__init__.py", line 47, in get_bearer_token
    async with aiohttp.ClientSession() as session:
               ~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 359, in __init__
    connector = TCPConnector(loop=loop)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 869, in __init__
    resolver = DefaultResolver(loop=self._loop)
  File "/usr/local/lib/python3.13/site-packages/aiohttp/resolver.py", line 96, in __init__
    self._resolver = aiodns.DNSResolver(*args, **kwargs)
                     ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiodns/__init__.py", line 67, in __init__
    self._channel = pycares.Channel(event_thread=True,
                    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
                                    timeout=timeout,
                                    ^^^^^^^^^^^^^^^^
                                    **kwargs)
                                    ^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/pycares/__init__.py", line 422, in __init__
    raise AresError('Failed to initialize c-ares channel')
pycares.AresError: Failed to initialize c-ares channel

---------------

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 9
  • Comments: 32 (19 by maintainers)

Commits related to this issue

Most upvoted comments

After disabling OctoPrint, the inotify statistics stay stable at about 20 watches with 2 instances. Before that, I was at >2000 instances.

Now I’m just curious what made this issue appear in 2025.05. The octoprint integration hasn’t changed much in the last months…

Maybe it was handled differently in aiohttp or another library that has been bumped?

Octoprint been leaking for a long time. There was a change in aiodns in 2025.5 to be able to detect network configuration changes that needs an inotify handle. While it was leaking before and slowly eating up memory it was a bit more obvious now that we run out of inotify handles as well

I think I figured out what goes wrong. I’ll post a issue for Octoprint soon, when I have everything clear and have an easy to reproduce example.

every new ClientSession of aiohttp initiates a aiodns instance. aiodns requires a inotify listener, so every ClientSession requires a inotify listener.

Most integrations using aiohttp use something like async with ClientSession() as session:, which closes the session after use. This doesn’t leak a listener.

The octoprint integration, and maybe also others, tries to handles it on it’s own, and fails:

https://github.com/home-assistant/core/blob/dev/homeassistant/components/octoprint/__init__.py#L181-L188

It only closes the session when Home Assistant exists, but not when the integration is reloaded. Every reload triggers this code path, which leaks the inotify listeners.

(This probably isn’t the best explanation, but I hope it helps others debugging this same issue)

Same problem here on multiple integrations (unifi, octoprint, dhcp)

You probably have a Octoprint integration which isn’t working. To fix the issue, disable the octoprint integration when your printer is offline. If that doesn’t fix it, let us know!

The issue should be fixed in 2025.05.2, which should be released on 16 May. With that version you can keep octoprint enabled without issues.

Sorry, I was offline most of the weekend. Yes, I also have the OctoPrint integration active, although the printer is offline. Thanks for the investigation!

That’s exactly the scenario me and @cyriax had, so it’s very much possible it’s only this integration. Great!

Now I’m just curious what made this issue appear in 2025.05. The octoprint integration hasn’t changed much in the last months…

I just isolated my issue to the octoprint integration, which is broken for me because my printer is currently offline. Disabling the integration and restarting keeps the inotify watches to just 5, with 2 instances.

@andyboeh, do you also have the Octoprint integration enabled, and is it working?

Or, do you have any other integrations that aren’t working? Could you try disabling all of them, and enabling them one-by-one?