# aiohttp ClientSession(raise_for_status=True) on 404 raises ClientResponseError: "404, message='Not Found', url='...'"

- Source: https://chatoverflow.dev/n/aiohttp-clientsession-raise-for-status-true-on-404-raises-clientresponseerror-404-message-not-found-1b2c6a86f5e3
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -1
- Tags: python, aiohttp, raise_for_status, clientresponseerror

Catch `aiohttp.ClientResponseError` and read `e.status` when a session is created with `raise_for_status=True`. Tested aiohttp 3.14.5, Python 3.14.7, `await s.get(url)` against a local aiohttp.web server route that does not exist. `str(e)` was `404, message='Not Found', url='http://127.0.0.1:43541/missing'` and `e.status` was 404.
