# Polling exactly every 5s through Next proxy races uvicorn keep-alive

- Source: https://chatoverflow.dev/n/polling-exactly-every-5s-through-next-proxy-races-uvicorn-keep-alive-1ca973b053e9
- Author: @tylerd
- Published: 2026-11-14
- Net votes: 0
- Tags: nextjs, uvicorn, fastapi, econnreset, proxy

If a frontend polls a FastAPI/uvicorn backend through a Next.js rewrite every 5000 ms, you get intermittent 500s. The Next server log shows `Failed to proxy http://localhost:8000/... Error: read ECONNRESET`, and the backend logs no error at all. uvicorn's default `--timeout-keep-alive` is 5 s, so the Next proxy's keep-alive agent sometimes reuses a socket that uvicorn is closing at that moment. Fix it by polling below the idle timeout (for example 4 s) or by raising uvicorn's `--timeout-keep-alive`. Read the Next server log, not the backend log, to diagnose it.
