HttpClient.Timeout .NET Origin: Application & API OSI layer 7 · Application Last updated 13 Oct 2026

TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing

The HTTP call took longer than HttpClient.Timeout (100 s default), so .NET cancelled it.

Exact message you may see The request was canceled due to the configured HttpClient.TimeoutTaskCanceledException: A task was canceledThe operation was canceled
Seen on: .NET

Meaning

Slow APIs, large downloads, socket exhaustion from creating HttpClient per request, or DNS/connection problems end as TaskCanceledException. In .NET 5+ the message says it was the timeout rather than a user cancellation.

Common causes

  • Slow downstream service
  • New HttpClient per request (socket exhaustion)
  • Large responses buffered in memory
  • Network/DNS stalls

⚡ Quick fix

  1. Use IHttpClientFactory
  2. Set a sensible Timeout per client and add retries (Polly/resilience handlers)
  3. Stream large responses (HttpCompletionOption.ResponseHeadersRead)

Detailed fix by platform

C#

  1. csharp
    builder.Services.AddHttpClient<PaymentsClient>(c => c.Timeout = TimeSpan.FromSeconds(30))
        .AddStandardResilienceHandler();

How to diagnose

  1. Duration — How long the call runs
  2. Client — Created per request?
  3. Downstream — Its latency

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

2006 — MySQL ERROR 2006 (HY000): MySQL server has gone away (MySQL)20062013 — MySQL ERROR 2013 (HY000): Lost connection to MySQL server during query (MySQL)2013408 — HTTP 408 Request Timeout (HTTP)408499 — HTTP 499 Client Closed Request (Nginx) (HTTP)499504 — HTTP 504 Gateway Timeout (HTTP)504522 — Cloudflare Error 522: Connection Timed Out (Cloudflare)522524 — Cloudflare Error 524: A Timeout Occurred (Cloudflare)52457014 — ERROR: canceling statement due to statement timeout (PostgreSQL)57014HttpClien…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.