IPC channel required but not established for child process
Production Risk
Low — caught immediately at call site; use fork() for inter-process messaging.
Thrown when child_process.fork() is used and the parent tries to send a message to the child but the IPC channel was not enabled. The IPC channel is required for fork() messaging; it is enabled by default with fork() but can be misconfigured.
- 1Using spawn() instead of fork() and then calling process.send() in the child
- 2Disabling the IPC channel by not including "ipc" in the stdio option of spawn()
- 3Calling child.send() on a process spawned without IPC
Triggered when process.send() or child.send() is used but no IPC channel was established.
const { spawn } = require('child_process');
const child = spawn(process.execPath, ['child.js']);
// No 'ipc' in stdio — child.send() throws
child.send('hello'); // throws ERR_CHILD_PROCESS_IPC_REQUIREDexpected output
Error [ERR_CHILD_PROCESS_IPC_REQUIRED]: Target process: /path/to/node child.js needs to be started with IPC channel
Fix 1
Use fork() instead of spawn() for IPC messaging
WHEN When you need to send messages between parent and child
const { fork } = require('child_process');
const child = fork('./child.js'); // IPC enabled by default
child.send({ hello: 'world' });
child.on('message', (msg) => console.log(msg));Why this works
fork() automatically sets up the IPC channel via the "ipc" stdio entry.
Fix 2
Enable IPC explicitly in spawn() stdio
WHEN When you need spawn() flexibility but also IPC
const { spawn } = require('child_process');
const child = spawn(process.execPath, ['child.js'], {
stdio: ['pipe', 'pipe', 'pipe', 'ipc'], // add 'ipc'
});
child.send('hello'); // now worksWhy this works
Including "ipc" in the stdio array establishes the IPC channel for spawn()-created processes.
const { spawn } = require('child_process');
const child = spawn(process.execPath, ['child.js']);
// No 'ipc' in stdio — child.send() throws
child.send('hello'); // throws ERR_CHILD_PROCESS_IPC_REQUIRED // this triggers ERR_CHILD_PROCESS_IPC_REQUIREDtry {
// operation that may throw ERR_CHILD_PROCESS_IPC_REQUIRED
riskyOperation()
} catch (err) {
if (err.code === 'ERR_CHILD_PROCESS_IPC_REQUIRED') {
console.error('ERR_CHILD_PROCESS_IPC_REQUIRED:', err.message)
} else {
throw err
}
}// Validate inputs before calling the operation
function safe_err_child_process_ipc_required(...args) {
// validate args here
return performOperation(...args)
}✕ Use spawn() without "ipc" in stdio and then call child.send()
Without the IPC channel there is no mechanism for message passing.
Node.js Error Codes Documentation
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev