Server-Sent Events Errors — SSE Connection and Streaming Failures
Warning5xx server error
Overview
Troubleshoot Server-Sent Events (SSE) connection drops, CORS issues, and buffering problems for reliable real-time HTTP streaming.
Key Details
- Server-Sent Events (SSE) provide one-way real-time data streaming from server to client over HTTP
- SSE connections use the text/event-stream content type and keep-alive HTTP connections
- Proxy servers and load balancers may buffer SSE responses, causing delayed or batched delivery
- Browser EventSource API automatically reconnects on connection drops with Last-Event-ID header
- Maximum concurrent SSE connections per domain is limited (6 in HTTP/1.1, higher in HTTP/2)
Common Causes
- Reverse proxy (Nginx/Apache) buffering the event stream instead of passing through immediately
- Load balancer idle timeout closing long-lived SSE connections after inactivity
- CORS headers missing on the SSE endpoint preventing cross-origin connections
- HTTP/1.1 connection limit (6 per domain) exhausted by multiple SSE connections
Steps
- 1Disable proxy buffering in Nginx: add 'proxy_buffering off;' and 'X-Accel-Buffering: no' header
- 2Set appropriate Cache-Control headers: 'no-cache, no-transform' to prevent intermediate caching
- 3Add CORS headers: Access-Control-Allow-Origin and Access-Control-Allow-Credentials for cross-origin SSE
- 4Implement heartbeat messages (empty comments) every 15-30 seconds to prevent idle timeout disconnections
- 5Use HTTP/2 to avoid the 6-connection-per-domain limit of HTTP/1.1
Tags
sseserver-sent-eventsstreamingreal-timeeventsource
More in 5xx Server Error
http-500-internal-server-errorHTTP 500 Internal Server Error — What It Means & How to Fix It
Criticalhttp-501-not-implementedHTTP 501 Not Implemented — What It Means & How to Fix It
Criticalhttp-502-bad-gatewayHTTP 502 Bad Gateway — What It Means & How to Fix It
Criticalhttp-503-service-unavailableHTTP 503 Service Unavailable — What It Means & How to Fix It
Criticalhttp-504-gateway-timeoutHTTP 504 Gateway Timeout — What It Means & How to Fix It
Criticalhttp-505-http-version-not-supportedHTTP 505 HTTP Version Not Supported — What It Means & How to Fix It
CriticalFrequently Asked Questions
SSE is one-way (server to client) over standard HTTP, with automatic reconnection. WebSocket is bidirectional over a separate protocol. SSE is simpler for scenarios where only the server pushes data.