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.
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
- Use IHttpClientFactory
- Set a sensible Timeout per client and add retries (Polly/resilience handlers)
- Stream large responses (HttpCompletionOption.ResponseHeadersRead)
Detailed fix by platform
C#
- csharp
builder.Services.AddHttpClient<PaymentsClient>(c => c.Timeout = TimeSpan.FromSeconds(30)) .AddStandardResilienceHandler();
How to diagnose
- Duration — How long the call runs
- Client — Created per request?
- 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:
Similar errors
Most viewed in .NET
- NullReferenceException System.NullReferenceException: Object reference not set to an instance of an object
- FileNotFoundException assembly Could not load file or assembly 'X, Version=…' or one of its dependencies
- InvalidOperationException InvalidOperationException: Unable to resolve service for type 'X' while attempting to activate 'Y'
Other ways to find it
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026