python network_error ai_generated partial

ClientDisconnected: Client disconnected while sending request body

ID: python/starlette-request-client-disconnect

Also available as: JSON · Markdown · 中文
80%Fix Rate
84%Confidence
0Evidence
2026-02-14First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

The client closes the connection before the request body is fully received.

generic

中文

客户端在请求体完全接收之前关闭了连接。

Workarounds

  1. 80% success
    Handle the exception gracefully and log it: except ClientDisconnected: logger.warning('Client disconnected')
  2. 70% success
    Use a middleware to catch and return a 499 status code

Dead Ends

Common approaches that don't work:

  1. 50% fail

    The request is incomplete; continuing may cause data corruption.

  2. 30% fail

    The client is gone; timeout won't help.