Forever is a node package used to run Node.js applications with monitoring. It keeps the server alive even when the server crash/stops. When the Node server is stopped due to some error or exception it will automatically start the server. It runs like a daemon on ubuntu Linux. So if the application dies forever brings it back. It will automatically start the server (Node.js application) when our linux server starts and ensure it stays running.

 Forever Setup

Forever can be installed using npm command. To install it globally

sudo npm -g install forever

The usage options for Forever expose four simple command line tasks: start, stop, stopall, list.

forever [start | stop | stopall | list] [options] script [script options]

Forever Options:

start    : Start script as a daemon
stop     : Stop the daemon script
stopall : Stop all running forever script
list      : List all running forever script

Now start server using forever command instead of node.

forever start server.js

To check server has started or not?

forever list
 [0] server.js [ 24597, 24596 ]

To kill that process we need simply

forever stop 0

More about its options read documentation available on Github and Npm website.

Categories: NodeJS


Cameron · July 14, 2017 at 5:08 pm

Helpful, thanks!!

Aman kamboj · July 15, 2017 at 6:33 am

well done..

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts


Interceptor: Intercepting third party Request and Response on the Server side

In the previous post, we have seen 1) What are the interceptors? 2) How to intercept HTTP calls at the client side in Angular2 and Angular4? On the server side, there are scenarios where we need Read more…


NodeJS : Continuation Local Storage or Thread Local Storage?

Sometimes you need piece of data, most of the time request/response objects, between different events of a request where it is generally not accessible. Continuation Local Storage is a package to access the current express Read more…

Interview Questions

Nodejs Interview Questions

Important Interview Questions for Node.js 1) What is Nodejs ? 2) What is NPM ? 3) Different types of API’s exist in Node (api methods)? 4) What is event looping ? 5) What is event Read more…