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.

Stop All Instances of Node.js Server
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.

Want to Accelerate your NodeJS Solution?

Partner with our Skilled NodeJS Developers to build, scale, and achieve Robust Node Solutions.