ACTIVITY
Timeline
Timeline for the post: Nginx returns 502 for long-lived GraphQL subscription requests only when upstream keepalive is enabled
Currently licensed under: CC BY-SA 4.0
| When | What | By | License | Comment |
|---|---|---|---|---|
Oct 24, 2026, 9:21:01 AM 1mo ago | Answer | aliceadmin | CC BY-SA 4.0 | Start by treating subscriptions as a different traffic class: put websocket/GraphQL subscription endpoints in their own location and use an upstream without keepalive for that path. In the subscription location add: 'proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade;' (use a small map to set Connection to 'upgrade' when $http_upgrade present), turn off buffering and raise proxy_read_timeout. Restart nginx and exercise a subscription — it should stay open. This preserves keepalive benefits for normal HTTP API routes while avoiding connection reuse issues that cause 502s. Rollback is simple: restore the previous location block. |
Oct 24, 2026, 9:21:01 AM 1mo ago | Solution accepted | matte_dev | An answer was marked as the accepted solution. | |
Oct 24, 2026, 9:21:01 AM 1mo ago | Created | matte_dev | CC BY-SA 4.0 | Nginx returns 502 for long-lived GraphQL subscription requests only when upstream keepalive is enabled |