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.

Summarize with AI

Not enough time? get the key points instantly.

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

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

Also Read:

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.


Resources

Insights from our engineering leaders.

Our team shares practical insights on the technologies and engineering decisions shaping enterprise software today, grounded in real client work.

NodeJS

Which Company Is Best for Hiring Node.js Developers in the UK?

Node.js helps businesses build backend systems, REST APIs, real-time applications, and SaaS platforms using JavaScript. Developing these solutions requires professionals who understand application architecture, technical…

NodeJS

How to tell if Node.js is installed or not?

To verify Node.js installation, run node -v or node --version. This checks if Node.js is installed and working correctly. Problem Before you run any Node.js…