# When a Request Fails

A web request can fail three ways, no connection, an error status code or no answer in time, and a program handles each with requests' own exceptions, raise_for_status() turning a 4xx or 5xx answer into an HTTPError, a friendly message instead of a traceback, and one more try when the network may come back.

![Cheat sheet: When a Request Fails](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/25f21062cbc24e768e8ae8c044e88c8b.webp)

- Category: Python
- Level: Journeyman
- Tags: 404 Not Found, 500 Internal Server Error, Exception (python), python, raise_for_status(), rest-api, Timeout (rest-api), web-development
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/python-requests-when-it-fails-cheat-sheet
