-
Notifications
You must be signed in to change notification settings - Fork 2.7k
pm2 stop/delete does not kill child worker processes (Next.js next-server orphaned) #6084
Description
Description
When managing a Next.js 15 app with pm2, the next start command spawns a child next-server worker process. When
running pm2 stop or pm2 delete, PM2 only kills the parent Node.js process — the child next-server worker
survives and continues holding the port.
This causes all subsequent pm2 start/pm2 restart commands to fail with EADDRINUSE because the orphaned child is
still bound to the port.
Steps to reproduce
- pm2 start node_modules/next/dist/bin/next --name my-app -- start -p 3002
- Confirm the child next-server worker is running: ss -tlnp | grep 3002 shows a next-server PID different from
the PM2-managed PID - pm2 stop my-app
- ss -tlnp | grep 3002 — the next-server child is still listening
- pm2 start my-app — fails with EADDRINUSE
Expected behavior
pm2 stop / pm2 delete should kill the entire process tree (parent + all children), not just the parent PID.
Environment
- PM2: 5.x
- Node.js: v22.x
- Next.js: 15.5.7
- OS: Ubuntu Linux
Workaround
Manually kill the orphaned process: ss -tlnp | grep to find the PID, then kill -9 .
You might also want to check if there's an existing issue first — search for "EADDRINUSE" or "treekill" or
"child process" on their issues page.