So I have Node/Express app running on an Amazon Linux Ec2 instance (VPC). The path to my node app is as follows /home/ec2-user/server/server.js

If I run which forever I get


If I run the following command the node app starts and works.

forever start server.js

If I reboot the server or stop/start then server.js will not run. I have to run forever start server.js from the terminal.

I tried the following ways to get my app to restart with forever and it will NOT restart.


forever start ../home/ec2-user/server/server.js

./.nvm/versions/node/v6.11.5/bin/forever start ../home/ec2-user/server/server.js


description "start kue server"

start on filesystem and started networking
stop on shutdown

  touch /var/log/forever.log
  touch /var/log/stat_out.log
  touch /var/log/stat_err.log
  rm /var/log/forever.log
  rm /var/log/stat_out.log
  rm /var/log/stat_err.log
  forever start -l /var/log/forever.log -o /var/log/stat_out.log -e /var/log/stat_err.log /home/ubuntu/code/StatKue/server.js
end script

crontab -e

forever start /server/server.js 

None of these works and I have spent 3 days trying to get forever to restart my app on reboot?

  • Why are you trying to use forever instead of just a normal systemd unit? – Michael Hampton Jan 9 '18 at 18:09
  • Forever is used for node applications. I have also tried pm2 but it also only works if I manually run the command. – jdog Jan 9 '18 at 21:05
  • I know what forever and pm2 are. They're generally not necessary on modern systems unless you're deploying into a Docker container though. – Michael Hampton Jan 9 '18 at 21:32
  • Either way the issue I believe is that where I put the call, any call to start the app it doesn’t seem to find the path. I have tried ../ ./ ~/ and local. Not sure if is a permissions issue or what? – jdog Jan 10 '18 at 0:02

In your rc.local use the absolute path to the server.js and the forever binary. Also make sure the rc.local is executable, chmod 755 rc.local

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.