Hi @Amjad Almaqbali , Thanks for sharing your details!
I took a closer look at the behavior you’re seeing where IIS suddenly closes the connection to your backend Python server and your logs show:
-
OSError: [WinError 64] The specified network name is no longer available
From what I can tell, this doesn’t point to an issue in your Python app. I believe what’s happening is that IIS is closing the backend TCP connection earlier than your ASGI server expects, so Uvicorn continues trying to use a socket that IIS has already dropped.
httpPlatformHandler will start your Python process and forward requests to it, but I think it’s important to note that it isn’t a full reverse proxy. It doesn’t give much control over backend connection lifetime, buffering, or long‑running async requests. Because Uvicorn often keeps connections alive longer than IIS’s defaults, IIS may decide that the backend request is “done” or “expired” and close the TCP connection:
- IIS forwards the request to your Python backend correctly.
- But if a connection stays open too long (long async work, idle period, or slow-running handler), I believe IIS may close it based on its internal timeout rules.
- When IIS closes the socket, Uvicorn tries to continue using it, which triggers WinError 64.
I also don’t think this is a Uvicorn issue, it’s more about how IIS manages backend connections in this setup.
Perhaps you could try out these suggestions first:
1. Increase httpPlatformHandler timeout values
I think increasing values like processTimeout and startupTimeLimit helps IIS avoid treating the backend process as unresponsive. This can reduce early connection drops.
2. Consider using ARR + URL Rewrite instead of httpPlatformHandler
If you want a more stable reverse proxy layer inside IIS, I suggest looking at Application Request Routing (ARR) with URL Rewrite. ARR provides proper proxy features like connection lifetime control and health management. This is also reflected in Microsoft’s ARR troubleshooting and configuration documentation here:
3. Use a dedicated reverse proxy if the setup allows it
If there’s flexibility, I think using NGINX or HAProxy in front of Uvicorn is usually the most stable approach. These tools handle long-lived keep-alive connections and async workloads much more predictably than IIS’s built-in forwarding.
Hope this helps! If you have any questions, please feel free to comment below. I'll be happy to assist!