---
title: "Fix SSE connection closed prematurely / EOF (SSE_CLOSED)"
slug: "sse-connection-closed"
code: "SSE_CLOSED"
category: "Network & Transport"
severity: "High"
canonical: "https://mcp-codex.com/errors/sse-connection-closed"
source: "MCP Codex (https://mcp-codex.com)"
dateModified: "2026-09-28"
---

# Fix SSE connection closed prematurely / EOF (SSE_CLOSED)

**Category**: Network & Transport | **Severity**: High

## Symptom
Remote SSE MCP servers disconnect intermittently or fail to keep long-running tool calls open.

## Root Cause
Reverse proxies (Cloudflare, Nginx, ALB) or corporate firewalls terminate idle HTTP streaming connections after 60–100 seconds when keep-alive heartbeats are missing.

## Remediation & Quick Fix
Implement a 15-second ping/heartbeat comment (`: keep-alive\n\n`) on the SSE endpoint and disable proxy buffering (`X-Accel-Buffering: no`).

## OS Remediation Commands

### MAC
```bash
# Test SSE stream headers with curl:
curl -N -H "Accept: text/event-stream" https://your-server.com/sse
```

### WINDOWS
```bash
# Test SSE stream endpoint:
curl.exe -N -H "Accept: text/event-stream" https://your-server.com/sse
```

### LINUX
```bash
# Test SSE stream endpoint:
curl -N -H "Accept: text/event-stream" https://your-server.com/sse
```

## Correct Configuration Example
```json
// Nginx Proxy Configuration:
location /sse {
    proxy_pass http://localhost:8000;
    proxy_set_header Connection '';
    proxy_http_version 1.1;
    chunked_transfer_encoding off;
    proxy_buffering off;
    proxy_cache off;
}
```

## Canonical Diagnostic Link
https://mcp-codex.com/errors/sse-connection-closed

## Weekly Protocol & Patch Diffs
Subscribe to verified runtime fixes and schema changes: https://mcp-codex.com#newsletter
