Your Search Bar For Shrewd Tips

How Do I Clear Pm2 List?


If your PM2 process list contains apps you no longer use, you can remove them with a PM2 command. The quickest option is pm2 delete all, which removes every process managed by the current PM2 daemon. If you only want to clear one entry, delete it by its name or ID instead. Before clearing the list, make sure you understand the difference between deleting processes, stopping them, and clearing their logs.

How to Clear the PM2 List

To remove every process from the PM2 list for the current user, run:

pm2 delete all

PM2 will remove the managed processes and their entries from the list. Then check the result with:

pm2 list

You can also use the shorter alias pm2 ls. If the deletion worked, the list should show no managed applications. This command affects the PM2 daemon and environment you are currently using; it does not automatically clear lists belonging to other system users or separate PM2 environments.

Deleting all is useful when you are cleaning up a development machine, preparing to redeploy an application, or removing processes that are no longer needed. Because it can stop several applications at once, confirm that you are connected to the correct server and user before running it.

Delete One Process Instead of the Entire List

If you want to keep some apps running, delete only the unwanted process. First, display the current list and find the process name or ID:

pm2 list

Then run one of these commands, replacing the example with the name or ID shown in your list:

pm2 delete my-app
pm2 delete 2

Deleting by name is often easier to recognize, while an ID can be convenient for a quick cleanup. Check the list again afterward to confirm that you removed the right entry.

For example, if your list contains a web application and a background worker, deleting the worker by name leaves the web application managed by PM2. This is usually safer than deleting everything when you are working on a shared server or a production system.

Delete, Stop, or Restart: What Is the Difference?

PM2 offers several commands that may seem similar, but they have different effects. Choose based on whether you want to remove an app, pause it, or keep it running with a fresh start.

  • pm2 delete <name|id>: Stops the selected process and removes it from the PM2 process list.
  • pm2 delete all: Stops and removes all processes managed by the current PM2 daemon.
  • pm2 stop <name|id>: Stops a process but keeps its entry in the list. You can start it again later.
  • pm2 restart <name|id>: Restarts a process while keeping it managed by PM2.

In other words, use stop when you might want to resume an app, and use delete when you want to remove it from PM2’s active process list. If your goal is specifically to clear the list, pm2 stop all is not enough: the stopped apps remain listed.

Clear PM2 Logs Without Removing Processes

Sometimes “clear the PM2 list” actually means clearing the log files shown or managed by PM2. Logs and process entries are separate. To empty the PM2-managed application logs without deleting or stopping your apps, use:

pm2 flush

This clears the log files for the processes managed by the current PM2 instance. It does not remove apps from pm2 list. Likewise, deleting a process is not the same as clearing every log file on your server. If your application writes logs to a custom location, pm2 flush may not affect those files.

To check where a process writes its output and error logs, inspect its details:

pm2 describe my-app

Use pm2 flush when you want to free space or start with empty PM2 logs. Use pm2 delete when you want to remove a managed process. Keeping those operations separate helps prevent accidental downtime.

Will the Processes Return After a Reboot?

PM2 can restore a saved process list when its startup service runs. If you previously ran pm2 save, the saved list may contain apps that you have since deleted. To make the saved process list match the currently empty list, delete the processes and then save the empty state:

pm2 delete all
pm2 save --force

The --force option matters when saving an empty list, because PM2 may otherwise ask for confirmation or refuse to overwrite a saved list with no processes. After saving, check the list again:

pm2 list

This is relevant if PM2 is configured to launch at system startup. Without updating the saved state, a startup service may resurrect processes from an older dump file. Exact startup behavior can depend on how PM2 was installed and configured, so verify your service setup if the apps reappear after a reboot.

If you only deleted processes temporarily and want them restored later, do not overwrite the saved list with an empty one. Saving an empty state replaces the previous saved process list, so use that step only when you intend to clear the startup-restored apps as well.

Does “pm2 reset all” Clear the List?

No. pm2 reset all resets process counters, such as restart or monitoring statistics, but it does not remove the processes from the PM2 list. If your goal is to remove every app, use:

pm2 delete all

If your goal is only to reset monitoring information while keeping the apps, then pm2 reset all may be appropriate. Check the command’s effect before using it, especially on a server where other people depend on the managed processes.

Should You Use pm2 kill?

pm2 kill shuts down the PM2 daemon and its managed processes. It is broader than deleting an individual app and is usually not the first command to try when you simply want to clean up the process list. It can be useful when you need to stop the PM2 daemon itself or troubleshoot a daemon that is not responding.

pm2 kill

Because PM2 may be configured to start again through a system service, killing the daemon does not necessarily erase a saved process list. The service may launch PM2 again, and saved apps may be restored. For a normal list cleanup, use pm2 delete all, then update the saved list with pm2 save --force if you also want to prevent those apps from being resurrected after a reboot.

Why Does the PM2 List Still Show Processes?

If a process remains visible after you run a delete command, check that you are looking at the same PM2 instance. PM2 is commonly run under a particular operating-system user. Running a command with sudo, for example, can connect you to a different user’s PM2 daemon than running it without sudo.

Use the same account and command context that originally started the processes. If your setup uses a custom PM2 home directory, the PM2_HOME environment variable may also point commands to a different process list. Useful checks include:

whoami
echo "$PM2_HOME"
pm2 list

Also consider whether you are using containers, multiple servers, or separate deployment environments. Each PM2 daemon has its own list, so clearing the list in one environment does not clear the others. On a shared production machine, confirm the user and environment before deleting processes.

Safe Checklist Before Clearing PM2

  • Run pm2 list and identify exactly which applications are managed.
  • Check whether any listed process serves live traffic or performs scheduled work.
  • Use pm2 delete <name|id> if you only need to remove one app.
  • Use pm2 delete all only when you intend to stop and remove every listed app for the current PM2 instance.
  • Use pm2 flush if you only want to clear PM2 logs.
  • Run pm2 save --force after deleting all only if you want the empty list to be restored at startup.
  • Verify the result with pm2 list and, when relevant, check the startup configuration.

These checks are especially important in production. Deleting a process can interrupt a website, API, worker, or scheduled task. If you are unsure what an entry does, inspect it with pm2 describe <name|id> before removing it.

Conclusion

To clear the PM2 process list, run pm2 delete all and verify the result with pm2 list. To remove just one app, use pm2 delete with its name or ID. Remember that pm2 stop keeps an entry in the list, pm2 flush clears logs rather than processes, and pm2 reset all resets counters rather than deleting apps. If you do not want deleted processes to return after a reboot, update the saved process list with pm2 save --force.


Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.

Shrewdnia

Shrewdnia

Shrewdnia is a destination for curious minds seeking clarity, knowledge, and informed perspectives. Through insightful articles and practical guides our passionate team explores a wide range of topics designed to help readers understand the world around them, make smarter decisions, and stay informed in an ever-changing landscape.


💡 Every question sparks discovery, and every perspective enriches the conversation. Share your thoughts and insights in the comments 👇

Back to blog

Leave a comment

JOIN THE SHREWDNIA COMMUNITY FORUM

What do you think?

Have an opinion, experience, or question about this topic? Join the Shrewdnia Forum and share your thoughts with other readers.

Join the Forum →