Stop a runaway Node.js process

Medium risk
What do risk levels mean?
Read-only
Inspects state without changing anything.
Low risk
Reversible with a routine follow-up command.
Medium risk
Changes state; undo path documented.
Destructive
Deletes or overwrites; confirmation required.

Finds Node.js processes, identifies the runaway one by CPU usage and command line, and stops it — gracefully first, forcefully only if needed.

nodeprocesskill

Parameters

Process id of the Node.js process to stop, from the inspect step.

Commands

List running Node.js processes with CPU usage and command lines

ps aux | grep '[n]ode'

Ask the process to terminate gracefully (SIGTERM)

kill <pid>

Force-kill only if the process ignored SIGTERM

kill -9 <pid>

Verification

ps -p <pid>

The process is no longer listed.

Undo

Not undoable

A stopped process cannot be resumed; restart it with its original command. Unsaved in-memory state is lost.

Pitfalls

  • SIGKILL (kill -9) skips cleanup handlers — the process cannot flush buffers or remove lock files; always try plain kill first.
  • Verify the command line before killing — dev servers, language servers, and editors all run node processes.
  • If the process is managed by a supervisor (pm2, systemd, nodemon), it will be restarted automatically; stop it through the supervisor instead.

Related