dotnet resource_error ai_generated true

SocketException: Only one usage of each socket address is normally permitted

ID: dotnet/connection-pool-exhaustion

Also available as: JSON · Markdown
80%Fix Rate
84%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
8 active

Root Cause

TCP connection/port exhaustion from HttpClient misuse.

generic

Workarounds

  1. 95% success Use IHttpClientFactory or static HttpClient instance
  2. 88% success Configure SocketsHttpHandler.PooledConnectionLifetime

Dead Ends

Common approaches that don't work:

  1. Create new HttpClient per request 92% fail

    Root cause of port exhaustion

  2. Increase ephemeral port range only 72% fail

    Delays problem, doesnt fix root cause