cloudflare/cloudflared · warning
Incoming request ended abruptly
Error message
Incoming request ended abruptly
What it means
In proxyHTTPRequest, the origin round trip (httpService.RoundTrip) failed AND the request context carried an error (canceled or deadline exceeded), meaning the CLIENT side of the request ended before the origin responded. The error is wrapped with this message instead of the generic origin-unreachable message.
Source
Thrown at proxy/proxy.go:224
if err == nil {
roundTripReq.ContentLength = int64(cLength)
}
}
// Request origin to keep connection alive to improve performance
roundTripReq.Header.Set("Connection", "keep-alive")
}
// Set the User-Agent as an empty string if not provided to avoid inserting golang default UA
if roundTripReq.Header.Get("User-Agent") == "" {
roundTripReq.Header.Set("User-Agent", "")
}
_, ttfbSpan := tr.Tracer().Start(tr.Context(), "ttfb_origin")
resp, err := httpService.RoundTrip(roundTripReq)
if err != nil {
tracing.EndWithErrorStatus(ttfbSpan, err)
if err := roundTripReq.Context().Err(); err != nil {
return errors.Wrap(err, "Incoming request ended abruptly")
}
return errors.Wrap(err, "Unable to reach the origin service. The service may be down or it may not be responding to traffic from cloudflared")
}
tracing.EndWithStatusCode(ttfbSpan, resp.StatusCode)
defer func() { _ = resp.Body.Close() }()
headers := make(http.Header, len(resp.Header))
// copy headers
for k, v := range resp.Header {
headers[k] = v
}
// Add spans to response header (if available)
tr.AddSpans(headers)
err = w.WriteRespHeaders(resp.StatusCode, headers)
if err != nil {View on GitHub (pinned to 2253eeeb25)
Solutions
- Check the wrapped context error: DeadlineExceeded means a timeout was hit; Canceled means the client went away.
- Tune timeout settings (originRequest connectTimeout / the edge request timeout) if origins are legitimately slow.
- Investigate why origins are slow enough to trigger client abandonment (slow queries, blocking work).
- If this happens during shutdowns, it is expected — treat it as a normal cancellation, not an origin failure.
Example fix
// before (config.yml) originRequest: connectTimeout: 5s # too short for slow origin // after originRequest: connectTimeout: 30s
Defensive patterns
Strategy: try-catch
Validate before calling
// Distinguish cancellation from origin failure before logging/alerting
if rctx := roundTripReq.Context(); rctx.Err() != nil {
log.Debug().Err(rctx.Err()).Str("path", r.URL.Path).Msg("client abandoned request")
return
} Try / catch
resp, err := httpService.RoundTrip(roundTripReq)
if err != nil {
if ctxErr := roundTripReq.Context().Err(); ctxErr != nil {
log.Debug().Err(ctxErr).Msg("request canceled by client; not retrying")
return
}
// otherwise: genuine origin failure — safe to retry
} Prevention
- Set originRequest timeouts generously enough for your origin's worst-case latency.
- Distinguish context.Canceled/DeadlineExceeded from real origin errors before alerting.
- Monitor client-abandonment rates as a signal of slow origins.
- Avoid retrying requests whose context is already canceled.
When it happens
Trigger: httpService.RoundTrip returns an error and roundTripReq.Context().Err() is non-nil — the client disconnected, the request timed out (context deadline), or cloudflared is shutting down and the context was canceled.
Common situations: Browsers/users canceling slow requests, origin timeouts shorter than origin processing time, aggressive proxy timeouts, or cloudflared shutdown mid-request.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
- Failed to proxy HTTP: %w
- internal error: unsupported connection type
- Failed to fetch resource
- failed to accept QUIC stream: %w
- unable to dial tcp to origin %s: %w
AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06).
Data as JSON: /api/errors/27be06f797713995.
Report an issue: GitHub.