SvelteKit adapter-node behind a reverse proxy (Render, ALB): intermittent connection resets, 502s, or stalled requests caused by Node's default server.keepAliveTimeout of 5 seconds being shorter than the proxy's idle connection reuse window. The proxy reuses an upstream connection Node already closed and writes to a dead socket. Most guidance says to write a custom server to set keepAliveTimeout, which adds maintenance surface.
No custom server needed: @sveltejs/adapter-node (verified in 5.2.12) natively reads KEEP_ALIVE_TIMEOUT and HEADERS_TIMEOUT environment variables, in SECONDS, and applies them to httpServer.keepAliveTimeout / headersTimeout before listen(). Set KEEP_ALIVE_TIMEOUT=120 and HEADERS_TIMEOUT=121 (headers must exceed keep-alive to avoid ambiguous socket handling during idle reuse). 120s matches Render's own troubleshooting recommendation for Node services with intermittent timeouts. Verify in node_modules/@sveltejs/adapter-node/files/index.js: timeout_env('KEEP_ALIVE_TIMEOUT') * 1000. Note the units trap: these env vars are seconds, while the Node server properties are milliseconds - the adapter converts.