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
- Handle the stream ‘error’ event
- Ignore EPIPE on stdout when piping to head
- Check the child process is alive before writing
Detailed fix by platform
Node.js
process.stdout.on('error', e => { if (e.code === 'EPIPE') process.exit(0); });
How to diagnose
- Writer — Which stream?
- Reader — Why did it close?
🧠 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026