Hass[]: OSError: [Errno 24] Too many open files

Since the 2022.8.* release I’ve found that I’m having to restart home assistant every couple of days, it goes very unresponsive and on checking the raspberrypi os log I’m getting this error: -

hass[]: OSError: [Errno 24] Too many open files

I’m running home assistant core (unsupervised) on a raspberry pi 4 (4GB) running raspberrypi os (buster) with python 3,9,9 and sqlite3 version 3.36.0 .

On investigating

lsof -u homeassistant | wc -l
1391
$ cat /proc/561/limits 
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        0                    unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             13167                13167                processes 
Max open files            1024                 524288               files     
Max locked memory         65536                65536                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       13167                13167                signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us

Open files whilst the problem occurring shows 1391, and the process limits for “max open files” shows 1024 for the soft limit,

I’ve increased the soft limit for the process within the systemd startup script to 2048.
That has stopped the open files error, but now I’m getting this: -

hass[]: 2022-08-16 19:23:47.599 WARNING (Thread-11) [pychromecast.socket_client] [Downstairs(192.168.1.54):32126] Error communicating with socket, resetting connection
hass[20458]: 2022-08-16 19:23:47.647 ERROR (Thread-11) [pychromecast.socket_client] [Downstairs(192.168.1.54):32126] Error in select call: filedescriptor out of range in select()

These are the only thing in the logs now, so I cannot go further back and tell what caused the issue.
I’ve not had this type of behaviour in previous versions when my chromecast devices were unavailable/switched off!

Any ideas?

Hi everyone,

I’m also experiencing the same here… Homeassistant Core on RPI (4Gb) on Debian Buster, py 3.9.9

Aug 20 17:20:59 raspberrypi hass[13197]: OSError: [Errno 24] Too many open files
Aug 20 17:20:59 raspberrypi hass[13197]: 2022-08-20 17:20:59.271 ERROR (MainThread) [homeassistant] Error doing job: socket.accept() out of system resource
Aug 20 17:20:59 raspberrypi hass[13197]: Traceback (most recent call last):
Aug 20 17:20:59 raspberrypi hass[13197]:   File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 164, in _accept_connection

lsof -u pi | wc -l
1847

I too am starting to see this recently, and frequently. Caught it only related to my Google Home devices so far, and usually when I make changes to my Google Home device configurations (combine two Home Minis to a pair) or powering on a Chromecast Audio that is usually offline. Requires restart of HA, or else the system gets flooded by these pychromecast errors and volume control is impacted.

Error in select call: filedescriptor out of range in select()
Error communicating with socket, resetting connection

Is there any bug ticket opened for this issue?