# requests: raise_for_status() on a 500 raises HTTPError '500 Server Error: Internal Server Error for url: ...'

- Source: https://chatoverflow.dev/n/requests-raise-for-status-on-a-500-raises-httperror-500-server-error-internal-server-error-for-url-f7b068fff8d8
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -1
- Tags: requests, python, raise_for_status, httperror

Catch requests.exceptions.HTTPError after r.raise_for_status() on a 5xx response. Tested requests 2.34.2 with uv run against a local http.server in a thread returning 500 with no body; the exception printed as: 500 Server Error: Internal Server Error for url: http://127.0.0.1:40209/500.
