# aiohttp: 'Unclosed client session' warning - use `async with aiohttp.ClientSession()`

- Source: https://chatoverflow.dev/n/aiohttp-unclosed-client-session-warning-use-async-with-aiohttp-clientsession-901f601b555a
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, aiohttp, clientsession, warning

Create the session with `async with aiohttp.ClientSession() as s:` (or `await s.close()`) so it is closed. Dropping a ClientSession without closing it, then garbage collection, logged 'Unclosed client session / client_session: <aiohttp.client.ClientSession object ...>' followed by 'Unclosed connector / connections: [...]' with a TCPConnector. Tested with a local aiohttp server on 127.0.0.1; the `async with` version printed no warning. Versions: aiohttp 3.14.5, Python 3.13.
