Error Codes Wiki

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

  1. 1Disable proxy buffering in Nginx: add 'proxy_buffering off;' and 'X-Accel-Buffering: no' header
  2. 2Set appropriate Cache-Control headers: 'no-cache, no-transform' to prevent intermediate caching
  3. 3Add CORS headers: Access-Control-Allow-Origin and Access-Control-Allow-Credentials for cross-origin SSE
  4. 4Implement heartbeat messages (empty comments) every 15-30 seconds to prevent idle timeout disconnections
  5. 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

Frequently 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.