Remove Node.js App from PM2 Process List

PM2 is a process manager that can help you to keep your Node.js server alive in the background. In this tutorial, you are going to learn how you can remove a Node.js app from the PM2 process list.

You may face a situation where you need to stop or remove or delete the Node app from PM2 process manager. So continue to follow this tutorial to learn how to perform this task…

Remove a single Node.js app from PM2 process

In order to delete a single item from the PM2 process list we need the process ID or process name for the running app in PM2 process list. Doing this is quite easy.

Below is the given command that will show the list of all the processes running in the background:

pm2 list

The above command shows the list of the process:

pm2 process lists

We can clearly see the process ID and name in the list. We can now delete or remove the specific Node.js app from the PM2 process list using either the ID or the name.

Delete Node.js process by the ID

Below is the command for removing the Node.js server from the pm2 process by providing its ID:

pm2 delete 2

It will delete the process with ID 2. To verify this, let’s check out the process list again:

pm2 list

pm2 list

Now we can not see the process item with ID 2. That means we are successfully able to remove it from the PM2 list.

Delete the process by the process name

Below is the given command in order to delete the process by the process name:

pm2 delete myapp

You can again verify it using the same command pm2 list as we did before to check out if the app was removed from the process list or not.

Remove all the Node.js apps from the PM2 process list

You may want to remove or delete all the running Node.js apps with a single command. Well, it is possible by running the command given below:

pm2 kill

After running the above command, you can see running pm2 list is now showing an empty list as you can see in the screenshot below:

pm2 process empty

The empty process means all the process from the pm2 process list has been deleted. That means, if you have multiple Node.js apps running with the PM2 process, then all of these will be deleted.

Leave a Reply

Your email address will not be published. Required fields are marked *