Skip to content
MtrXTools

curl: (18) transfer closed with outstanding read data remaining

The connection closed before the body finished

Seen in curl, libcurl (CURLE_PARTIAL_FILE), Git over HTTPS

The server or something in between closed the connection before sending the full response body it announced.

Common causes

  • The application crashed or was killed mid-response, so the Content-Length or chunked body was cut short.
  • A proxy, load balancer or CDN timed out a slow or large response and closed the connection.
  • A wrong Content-Length header that is larger than the body actually sent.
  • An unstable network path dropping a long transfer.

How to fix it

  1. Check application and proxy logs at the time of the request for crashes or timeouts.
  2. Raise idle and response timeouts on the proxy or load balancer for large downloads.
  3. Make sure the application does not set Content-Length by hand when compression or middleware changes the body.
  4. Retry with -C - to resume a large download, and compare from another network.
Check the response headers

Got a different message? Paste it into the error explainer.

Related errors

All 34 Command line & code errors