Hi everyone,
I’m currently working on deploying a Node.js application to a DigitalOcean Droplet, and I’m running into a few challenges. I’ve created the droplet and installed Node.js using the official guide, but I’m having trouble getting the app to run in the background and ensuring it stays online after I disconnect from the SSH session.
Here’s what I’ve done so far:
node app.js
, but the process stops when I disconnect.What I need help with:
Any help or advice would be greatly appreciated!
Thanks in advance for your time and support!
Best, Jsoon Hook!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
Yes, you’ll want to use PM2 to keep your Node.js app running in the background and restart it if the server reboots. Here’s how to set it up on your DigitalOcean Droplet:
Install PM2 globally:
Start your app with PM2:
This keeps your app running even after you close SSH.
You can also use Git and GitHub to manage your code and deploy updates more easily instead of SFTP.
Also make sure to check out this guide for a more detailed setup: How to Use PM2 to Set Up a Node.js Production Environment.
Hope that this helps!
- Bobby