EventSource HTTP Origin: Network OSI layer 7 · Application Last updated 18 Nov 2026

EventSource keeps reconnecting (error event / server closes stream)

The browser's EventSource reconnects again and again, hammering the server.

Exact message you may see EventSource's response has a MIME type that is not "text/event-stream". Aborting the connection.EventSource connection keeps reconnectingEventSource failed: Last-Event-IDEventSource reconnecting loopnet::ERR_INCOMPLETE_CHUNKED_ENCODING EventSource
Seen on: HTTP JavaScript Node.js

Meaning

Any closed connection or non-200/wrong Content-Type response triggers an automatic reconnect (default 3 s). Return Content-Type: text/event-stream with status 200, keep the connection open with heartbeats, honour retry: and id: / Last-Event-ID, and send 204 to stop reconnecting.

Common causes

  • Wrong Content-Type or status code
  • Server/proxy closes the stream after a timeout
  • Auth failure returning 401/redirect
  • App crashes between events
  • Short retry value

⚡ Quick fix

  1. Send Content-Type: text/event-stream and keep it open
  2. Heartbeat comments every 15–30 s
  3. Return 204 to stop clients permanently

Detailed fix by platform

JavaScript

  1. javascript
    const es = new EventSource("/events");
    es.onerror = () => console.log("readyState", es.readyState);

How to diagnose

  1. Status/type — 200 text/event-stream?
  2. Stream — Closed by timeout?
  3. Auth — Valid?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

102 — HTTP 102 Processing (HTTP)102201 — HTTP 201 Created (HTTP)201202 — HTTP 202 Accepted (HTTP)202203 — HTTP 203 Non-Authoritative Information (HTTP)203401 — HTTP 401 Unauthorized (HTTP)401SSE — Server-Sent Events arrive all at once (proxy buffering / compression) (HTTP)SSEWebSocket 1006 — WebSocket closed with code 1006 (abnormal closure) (HTTP)WebSocket 1006EventSour…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.