Disclosure: We earn commissions when you shop through the links below.
Setting up a server correctly is just as important as writing good code. Many Node.js applications fail in production not because of bugs, but because the server was poorly configured. A missing firewall rule, insecure SSH access, or incorrect process management can easily cause downtime or security issues.
This guide provides a practical DigitalOcean droplet setup checklist for Node.js apps. It is written for developers who want a clean, secure, and production-ready environment before deploying their application. Whether you are hosting an API, a full-stack app, or a background worker, this checklist will help you avoid common mistakes.
To follow this checklist, you will need a Linux server with full control over the environment. Many developers choose DigitalOcean because it offers simple Droplet creation, predictable pricing, and reliable performance for Node.js production workloads.
Before deploying your application, it’s important to prepare the server properly. If you’re looking for a complete walkthrough, you can follow my step-by-step guide on how to deploy React & Node.js on DigitalOcean, which covers the full production deployment process.
Why Proper Droplet Setup Matters for Node.js
A DigitalOcean droplet is essentially a Linux server. By default, it comes with minimal configuration. While that is good for flexibility, it also means you are responsible for security, performance, and reliability.
A proper setup helps you:
- Prevent unauthorized access
- Keep your Node.js app running continuously
- Improve performance and stability
- Reduce debugging time later
- Prepare your app for future scaling
Skipping these steps often leads to production issues that are harder to fix once users are affected.
Prerequisites Before You Start
Before starting this checklist, make sure you have:
- A DigitalOcean account
- A basic understanding of Linux commands
- SSH access from your local machine
- Node.js project ready for deployment
This guide assumes you are using Ubuntu 22.04, which is commonly used for Node.js production servers.
Step 1: Create the DigitalOcean Droplet
Start by creating a new droplet from the DigitalOcean dashboard.
Recommended options:
- Image: Ubuntu 22.04 LTS
- Plan: Basic shared CPU
- Size: 1GB RAM is enough for small Node.js apps
- Authentication: SSH key instead of password
- Datacenter: Closest to your users
Once the droplet is created, note down its public IP address.
Step 2: Connect to the Server Using SSH
From your local machine, connect to the droplet:
ssh root@your_server_ip
Once logged in, update the system packages:
apt update && apt upgrade -y
This ensures your server has the latest security patches.
Step 3: Create a Non-Root User
Running everything as root is risky. A safer approach is to create a new user and grant sudo access.
Create a user:
adduser deployer
Add the user to the sudo group:
usermod -aG sudo deployer
Switch to the new user:
su - deployer
This simple step improves server security significantly.
Step 4: Secure SSH Access
To prevent brute-force attacks, disable root login and password authentication.
Edit the SSH configuration:
sudo nano /etc/ssh/sshd_config
Update these values:
PermitRootLogin no
PasswordAuthentication no
Restart SSH:
sudo systemctl restart ssh
Now your server only allows SSH key-based access.
Step 5: Configure Firewall on DigitalOcean
Firewall setup is an essential part of any digitalocean server security checklist.
Enable UFW:
sudo ufw enable
Allow SSH access:
sudo ufw allow OpenSSH
Allow web traffic:
sudo ufw allow 'Nginx Full'
Check firewall status:
sudo ufw status
This ensures only required ports are open.
Step 6: Install Node.js and npm
Install Node.js using NodeSource for better compatibility.
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
Verify installation:
node -v
npm -v
This completes the basic Node.js server setup on DigitalOcean.
Step 7: Install PM2 for Process Management
PM2 keeps your Node application running even if it crashes or the server restarts.
Install PM2 globally:
sudo npm install pm2 -g
Enable PM2 startup on boot:
pm2 startup
Run the command shown in the output, then save the process list:
pm2 save
This step is critical for pm2 setup for Node.js production environments.
Step 8: Prepare Application Directory Structure
Create a clean directory structure for your app:
mkdir ~/apps
mkdir ~/apps/node-api
cd ~/apps/node-api
Upload your Node.js project using Git or SCP.
Install dependencies:
npm install
Avoid running apps directly from the home directory. Organized folders make maintenance easier.
Step 9: Configure Environment Variables
Never hardcode secrets in your code.
Create a .env file:
nano .env
Example:
NODE_ENV=production
PORT=5000
DATABASE_URL=your_database_url
Make sure .env is not committed to Git.
This is a core part of node js production environment setup.
Step 10: Start the Node.js App with PM2
Start your application:
pm2 start index.js --name node-api
Check status:
pm2 status
View logs:
pm2 logs
Your Node.js app is now running reliably in the background.
Step 11: Install and Configure Nginx
Nginx acts as a reverse proxy and improves performance.
Install Nginx:
sudo apt install nginx -y
Create a server config:
sudo nano /etc/nginx/sites-available/node-api
Add:
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Enable config:
sudo ln -s /etc/nginx/sites-available/node-api /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
This completes nginx setup for Node.js app.
Step 12: Enable SSL for HTTPS
Install Certbot:
sudo apt install certbot python3-certbot-nginx -y
Run SSL setup:
sudo certbot --nginx -d yourdomain.com
HTTPS improves security and SEO and is required for modern browsers.
Step 13: Enable Server Monitoring and Backups
In the DigitalOcean dashboard:
- Enable monitoring alerts
- Enable automatic backups
- Track CPU and memory usage
Monitoring helps detect memory leaks and performance issues early.
Step 14: Final Production Checks
Before deploying your app publicly, confirm:
- Firewall is active
- SSH root login is disabled
- PM2 is running
- Nginx config is valid
- Environment variables are secure
- SSL is working
This completes your digitalocean droplet checklist.
Common Mistakes to Avoid
- Running Node.js directly without PM2
- Leaving SSH password login enabled
- Forgetting firewall rules
- Not monitoring memory usage
- Storing secrets in code
Avoiding these saves hours of debugging later.
Missing any of the above steps can lead to serious deployment problems later. To avoid common mistakes, refer to this list of DigitalOcean deployment errors and fixes that developers often face.
When to Scale Your Droplet
If you notice:
- High memory usage
- Frequent PM2 restarts
- Slow API responses
You can resize the droplet or add load balancing. DigitalOcean makes scaling simple when your app grows.
Once your droplet is fully configured, the next step is deploying your application. Check out this detailed guide on deploying React and Node.js on DigitalOcean.
Final Thoughts
A solid server setup is the foundation of every successful Node.js application. This DigitalOcean droplet setup for Node.js checklist ensures your app is secure, stable, and production-ready from day one.
Once your server is configured correctly, deploying React or backend services becomes much easier. Investing time in setup now will save you far more time in the future.
Worth reading: Optimizing Node.js Performance: Pro Tips for Developers
Frequently Asked Questions
Q1: Do I need a powerful Droplet for a Node.js app?
No, most Node.js applications run perfectly on a basic DigitalOcean Droplet with 1GB RAM. This is enough for APIs, small apps, and early production traffic. You can always scale the Droplet later if your app starts consuming more CPU or memory.
Q2: Is Nginx mandatory for running Node.js on DigitalOcean?
Nginx is not mandatory, but it is strongly recommended for production. It helps handle incoming traffic, improves performance, and allows you to run your Node.js app securely behind a reverse proxy. It also makes SSL setup much easier.
Q3: How often should I update my DigitalOcean server?
It’s a good practice to update your server at least once a month. Regular updates help fix security vulnerabilities and keep system packages stable. You should also monitor CPU and memory usage to catch issues early before they affect users.

Ankit Kumar is a senior software engineer with 8+ years of experience working on production web applications using React, Angular, Node.js, SAP UI5, and JavaScript. He writes technical articles covering frontend, backend, and server-side topics, with a focus on real-world production issues and performance optimization.









