---
title: "Can async deadlocks happen with HttpClient and IHttpClientFactory?"  
description: "Can async deadlocks happen with HttpClient and IHttpClientFactory?"  
author: "Amrith Chandran"  
published: 2026-09-21  
canonical: https://answers.mindstick.com/qa/117246/can-async-deadlocks-happen-with-httpclient-and-ihttpclientfactory  
category: "networking"  
tags: ["networking", "httpclient", ".NET"]  
reading_time: 1 minute  

---

# Can async deadlocks happen with HttpClient and IHttpClientFactory?

## HttpClient Gotchas

`HttpClient` is designed to be instantiated once and reused. Misusing it—such as creating a new instance per request or calling `SendAsync` synchronously via `.Result`—can exhaust sockets and trigger [deadlocks](https://answers.mindstick.com/qa/116612/explain-deadlocks-in-sql-server-and-how-to-prevent-them) under load.

### Specific Risks

When you wrap `HttpClient.SendAsync` in a `Task.Run` and then block on it, you force the operation onto a thread-pool thread while the original context waits. If that context is a UI thread or a request thread with limited concurrency, the pool starves. `IHttpClientFactory` helps by managing handler lifetimes, but it does not magically fix blocking awaits.

Always await `SendAsync` directly. If you must call it from sync code, use `SendAsync` with `ConfigureAwait(false)` and ensure the surrounding method is also async. Never call `.GetAwaiter().GetResult()` inside a library meant for UI consumption.


---

Original Source: https://answers.mindstick.com/qa/117246/can-async-deadlocks-happen-with-httpclient-and-ihttpclientfactory

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
