Node.js pm2 keeps restarting almost every second
pm2 writes application logs to ~/.pm2/logs
and pm2 specific logs to pm2.log
by default. We need to check both the locations to debug the issue.
One other way to debug application is by starting the application manually, ie., something like npm run start
or node path/yo/your/bin.js
It should give you the missing piece of information to fix the problem and move on.
Check if your app modifies a file in the project folder (such as a log file). A change to any of the files triggers restart if watch
flag is enabled.
To prevent this, use a process
file and add watch_ignore
flag in it.
Here's a documentation on how to use the process file: PM2 - Process File