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!
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:
npm install -g pm2
Start your app with PM2:
pm2 start app.js --name my-node-app
pm2 save
pm2 startup
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.