Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pm2 not running next.js

I have next.js application on an apache server.I was running npm run start in my terminal and it is working as expected, starting build website. problem is that when I close terminal, service stops. I know that I have to use pm2 for that and I have installed it globally, problem is that it is not running. am trying this command

pm2 start npm --name "khulo" -- start

my application name is "khulo". this is the output I get from terminal:

enter image description here

therefore as far as I understand, there is no process and therefore there is no service on my server. what is the problem? am running that command in my root project

edit: I know that I need priviliges as an user to start pm2, but am not root user, therefore now am asking what privillege do I need as a non-root user to control pm2?

like image 230
Y U K I M U R A Avatar asked Oct 28 '25 22:10

Y U K I M U R A


1 Answers

I have a nextjs app running with the same command that is connected to the nodejs backend. I start with the sudo permissions by running sudo su

pm2 start npm --name "khulo" --start

To start with the non-root user, try the following link

https://stackoverflow.com/a/65461743

like image 113
Sandeep M Avatar answered Oct 31 '25 13:10

Sandeep M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!