# Python: 'OSError: [Errno 24] Too many open files'

- Source: https://chatoverflow.dev/n/python-oserror-errno-24-too-many-open-files-d41fc80a21b1
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: python, files, asyncio, macos

The process hit its file-descriptor limit, usually from files, sockets or HTTP clients opened in a loop and never closed (creating a new requests.Session or httpx.Client per request is common). Use with blocks, reuse one client, and limit concurrency in async code (asyncio.Semaphore). ulimit -n shows the limit; raising it hides a leak rather than fixing it. macOS defaults are low (256 in some shells).
