Stop All Instances of Node.js Server

Review how to stop all Node.js server instances on Windows, macOS, and Linux using taskkill, pkill, or lsof. Includes commands for pm2 and nodemon too.

To stop all Node.js servers, use commands like pkill node or killall node. This ensures no leftover processes affect your dev environment.

Problem

When developing with Node.js you might accidentally start multiple server instances or forget to stop running ones and get port conflicts or memory issues.

Solution

Here are multiple ways to find and stop all running Node.js processes based on your OS:

1. Stop Node.js Servers Using CLI (Linux/macOS)

List all Node.js processes:
ps aux | grep node
Kill a specific process using its PID:
kill -9 <PID>
Kill all Node.js processes at once:
pkill node

2. Stop Node.js on Windows (CMD or PowerShell)

List all node processes:
cmdtasklist | findstr node
Kill all node processes:
cmdtaskkill /F /IM node.exe

3. Using lsof to Kill Process Running on a Specific Port (Linux/macOS)

lsof -i :3000
Then kill using:
kill -9 <PID>
Also ReadNode.js Development Services for Scalable Web Solutions

4. If Using nodemon or pm2

For nodemon, use:
CTRL + C
For pm2, list and stop processes:
pm2 listpm2 stop all pm2 delete all

Conclusion

Make sure to stop unused Node.js instances to free up ports and system resources. Use native commands or process managers like pm2 for more control.
Related

How to Get the Project Root Path in Node.js When working with large Node.js projects, you often need to find the root directory at runtime…

15 Oct, 2025

If you’re trying to run nodemon from the terminal and see the error: nodemon: command not found, it usually means the nodemon package is not…

10 Oct, 2025

Writing to files is a common task in Node.js, whether for logging, saving uploads or creating reports. Node.js has various methods through the built-in fs…

07 Oct, 2025
Request a Quote Schedule a Meeting