Benjamin
Benjamin

Reputation: 3826

Getting error when trying to launch node.js app with PM2 Cluster

in an Ubuntu Server, I am unable to run the node.js app in cluster mode using PM2.

The command I use is :

PM2 start server.js --name Server -i max

When I list the PM2 processes, I can see the Server has Error status. I have tried looking into the log file generated by PM2 but it's empty.

I am however able to run the same server.js without the cluster mode using :

PM2 start server.js --name Server

Upvotes: 8

Views: 35145

Answers (3)

Akhil S
Akhil S

Reputation: 1181

I have gone through this same kind of situations but in my case pm2 is showing error status cause of error in my code. use the below command

pm2 logs

pm2 logs command helped me by showing some hints to check where exactly the error is occured.

if everything works fine then pm2 list will show you the status online.

you can check the ports running by pm2(not only pm2 but all the process) using below command

sudo netstat -tulpn

Upvotes: 4

Benjamin
Benjamin

Reputation: 3826

doing PM2 Kill and starting all the services again was the solution to above issue.

Upvotes: 24

BraveButter
BraveButter

Reputation: 1458

You could also have used pm2 restart Server to restart it

If you use pm2 kill you will just kill all processes, to clean up afterwards i would recommend to use pm2 flush so all logfiles will be reset

Upvotes: 9

Related Questions