Use a combination of the nohup prefix command (to prevent the process from being killed when the terminal closes) and the & suffix (to start the process in the background so that it does not bind the terminal): nohup node example.js &
You should also look into forever or similar tools, which will also automatically restart the server if it works, and nodemon , which will automatically restart it when the code changes.
source share