EPIPE Node.js Origin: Application & API Last updated 13 Oct 2026

Error: write EPIPE

Node wrote to a pipe or socket whose other end was already closed.

Seen on: Node.js

Meaning

Piping output to a command that exits early (head, grep -q), clients disconnecting mid-response, or child processes that died.

Common causes

  • Downstream process closed stdin (e.g. node script.js | head)
  • Client disconnected during a stream
  • Child process exited before you wrote to it

⚡ Quick fix

  1. Handle the stream ‘error’ event
  2. Ignore EPIPE on stdout when piping to head
  3. Check the child process is alive before writing

Detailed fix by platform

Node.js

  1. process.stdout.on('error', e => { if (e.code === 'EPIPE') process.exit(0); });

How to diagnose

  1. Writer — Which stream?
  2. Reader — Why did it close?

🔧 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: Application & API. Errors that are often confused with or caused by this one (click to open):

Cannot allocate memory — fork: Cannot allocate memory / ENOMEM (Linux)Cannot allocate memoryEADDRINUSE — Error: listen EADDRINUSE: address already in use :::3000 (Node.js)EADDRINUSEERR_STREAM_PREMATURE_CLOSE — Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close (Node.js)ERR_STREAM_PREMATURE_…fork: retry: Resource temporarily unavailable — fork: retry: Resource temporarily unavailable (process/thread limit) (Linux)fork: retry: Resource…KeyboardInterrupt — KeyboardInterrupt (script stopped with Ctrl+C) / ^C traceback (Python)KeyboardInterruptmaxBuffer exceeded — RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded (Node.js)maxBuffer exceededOSError Errno 98 — OSError: [Errno 98] Address already in use (Python)OSError Errno 98spawn EACCES — Error: spawn EACCES (Node.js)spawn EACCESEPIPE

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.