dotnet
resource_error
ai_generated
true
SocketException: An existing connection was forcibly closed
ID: dotnet/http-client-factory-leak
80%Fix Rate
84%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 8 | active | — | — | — |
Root Cause
HttpClient DNS caching or socket leak.
genericWorkarounds
-
92% success Use IHttpClientFactory with managed lifetime
-
88% success Set PooledConnectionLifetime to 2-5 minutes
Dead Ends
Common approaches that don't work:
-
Dispose HttpClient after every use
82% fail
Creates new connections each time
-
Use static HttpClient with infinite lifetime
78% fail
DNS changes never picked up