ERR_STREAM_PREMATURE_CLOSE 🟩 Node.js

Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close

A stream ended or was destroyed before it finished — often a client disconnect or upstream aborting a download.

Seen on: Node.js

Meaning

stream.pipeline/finished report this when a source or destination closes early. In HTTP servers it means the client went away; in clients it means the server cut the response.

Common causes

  • Client aborted the request
  • Upstream closed the response early
  • Destroying a stream manually before it finished

⚡ Quick fix

  1. Treat it as a client-abort in servers (don’t log as an error)
  2. Retry downloads
  3. Use stream.pipeline to clean up properly

Detailed fix by platform

Node.js

  1. await pipeline(src, transform, dest); // rejects on premature close

How to diagnose

  1. Side — Which end closed?
  2. Timing — Client navigated away?

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