11/11/2026
HttpClient DNS changes can leave a .NET service calling an old server through reused connections. A healthy replacement is not enough if callers keep using the route that existed before the cutover.
A host name is not a live subscription to its current address. HttpClient resolves DNS when it creates a connection. If it reuses an existing connection, that socket still leads to the endpoint it originally reached.
The common mistake is assuming that a long-lived client automatically follows DNS record expiry. HttpClient does not track DNS TTLs itself. The opposite fix, creating and disposing a new client with its own handler for every request, adds connection churn and can exhaust ports under load.
For real projects, choose a lifetime strategy deliberately:
- Share a long-lived client backed by SocketsHttpHandler and configure PooledConnectionLifetime. The two-minute value in the example is illustrative; choose an interval for your expected network changes.
- Or create short-lived clients through IHttpClientFactory, which manages pooled handlers. Do not capture a factory-created client forever and expect handler rotation to update it.
- Keep old endpoints available through the planned overlap, then observe traffic reaching the new target before retiring the old one.
Connection lifetime is not a request timeout. Expiry does not interrupt an active request, and replacement connections are created as needed. OS DNS caches, proxies and load balancers can also affect the actual route, so this setting does not guarantee an exact cutover time.
The code shows configuration patterns, not complete application bootstrapping. Share the configured client once, dispose responses after consuming their bodies, and keep request deadlines and safe retry rules as separate decisions.
The carousel includes a cutover checklist and a sustained-traffic test. A healthy replacement server is only half the evidence; the other half is proving callers actually reach it.
After a dependency changes address, what signal proves your callers have moved to the new endpoint?