Skip to content

pm2 stop/delete does not kill child worker processes (Next.js next-server orphaned) #6084

@iAccelTech

Description

@iAccelTech

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

  1. pm2 start node_modules/next/dist/bin/next --name my-app -- start -p 3002
  2. Confirm the child next-server worker is running: ss -tlnp | grep 3002 shows a next-server PID different from
    the PM2-managed PID
  3. pm2 stop my-app
  4. ss -tlnp | grep 3002 — the next-server child is still listening
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions