Sanjai
Junior DevOps Engineer

My name is Sanjai and I work as a Junior DevOps Engineer at CloudHouse Technologies — a cloud, ERP, and web development company based in Kerala, India.
1.1 Why I Wrote This Guide
As part of my role at CloudHouse, I was tasked with researching and documenting the best way to deploy Next.js applications to cloud servers — specifically Vultr — for our clients.
Most deployment guides I found online were either:
So I put together this guide from scratch — combining official documentation, tested commands, and deployment best practices — into one clear, step-by-step reference that anyone can follow.
1.2 What This Guide Covers
This is not just another copy-paste tutorial. Here is what makes it different:
1.3 Who This Guide Is For
1.4 Tools and Stack Used
Last updated: April 2026 — reflects current Node.js LTS, latest Certbot commands, and modern Nginx configuration best practices.
Before jumping into the steps, let me quickly explain what Next.js is and why Vultr is a strong choice for hosting it.
2.1 What is Next.js?
Next.js is a React-based framework developed by Vercel. Unlike a plain React app, Next.js supports:
2.2 Why Not Just Use Vercel?
Vercel is the official hosting platform for Next.js and is excellent for small or personal projects. However it has real limitations for client work:
Cost at Scale • Vercel's free tier has strict bandwidth limits • Costs increase quickly for high-traffic production applications
Limited Server Control • You cannot customise the server environment • Some enterprise features require expensive plans
Client Data Privacy • Many clients require their data to remain on their own dedicated infrastructure • Self-hosted cloud servers give complete data ownership and control
2.3 Why Vultr?
Vultr is one of the most developer-friendly cloud providers available today. Here is why it is a strong choice for Next.js deployments:
Flexible Plans • Multiple server sizes to match any client budget • Scale up or down based on project requirements
Global Data Centres • Locations across Asia, Europe, and the Americas • Choose the region closest to your users for best performance
Simple Control Panel • Easy to set up and manage even for beginners • One-click OS installation with Ubuntu 22.04 LTS
Reliable Performance • High-frequency NVMe SSD storage • Consistent uptime for production applications
Transparent Pricing • No hidden fees • Pay only for what you use
Before you start the deployment, make sure everything below is in place. Skipping any of these steps is the most common reason deployments fail.
3.1 Local Requirements
Important: Always test your production build locally before deploying to any server.
Run these commands locally first: npm run build npm start
If your app works locally in production mode, it will work on the server too.
3.2 Vultr Server Requirements
Recommended minimum specs for a basic Next.js app:
3.3 Networking Requirements
Make sure these ports are open in your Vultr server firewall:
3.4 Optional but Strongly Recommended
3.5 One Step Most Tutorials Skip
The most common reason Next.js deployments fail silently is a missing or incomplete .env file on the server.
Your app may build successfully but crash at runtime if environment variables are missing.
Always create your .env.production file on the server before running npm run build — not after.
Step 1 — Connect to your server
Use SSH to connect: ssh root@your-server-ip
Step 2 — Install Node.js on the server
Run: curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
Then: sudo apt-get install -y nodejs
Step 3 — Clone your project from GitHub
Run: git clone https://github.com/yourusername/your-nextjs-project.git
Then: cd your-nextjs-project
Step 4 — Install dependencies
Run: npm install
Step 5 — Build the project
Run: npm run build
Step 6 — Start the app
Run: npm start
Your app is now running on port 3000 by default.
Step 7 — Keep it running with PM2
Install PM2: npm install -g pm2
Start with PM2: pm2 start npm --name "nextjs-app" -- start
Auto-restart on reboot: pm2 startup && pm2 save
Here is the exact step-by-step process to deploy your Next.js app to a Vultr server. Follow each step in order.
4.1 Step 1 — Connect to Your Server via SSH
Open your terminal and connect to your Vultr server: ssh root@your-server-ip
Replace your-server-ip with the IP address shown in your Vultr control panel.
4.2 Step 2 — Update Your Server
Always update packages on a fresh server first: sudo apt update && sudo apt upgrade -y
4.3 Step 3 — Install Node.js 18 LTS
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install -y nodejs
Verify installation: node -v npm -v
Note: Always use the LTS version of Node.js for production. Avoid experimental versions as they can cause unexpected compatibility issues.
4.4 Step 4 — Install Git and Clone Your Project
Install Git: sudo apt install git -y
Clone your project from GitHub: git clone https://github.com/yourusername/your-nextjs-project.git cd your-nextjs-project
4.5 Step 5 — Add Your Environment Variables
This is the step most tutorials skip entirely.
Create your environment file on the server: nano .env.production
Add all your environment variables here exactly as they appear in your local .env file.
Save and exit: Ctrl+X, then Y, then Enter
4.6 Step 6 — Install Dependencies
npm install
4.7 Step 7 — Build the Project
npm run build
4.8 Step 8 — Test the App is Running
Before setting up PM2, confirm the app runs correctly: npm start
Open your browser and visit: http://your-server-ip:3000
If you can see your app — everything is working. Press Ctrl+C to stop it and proceed to the next step.
4.9 Step 9 — Keep It Running with PM2
PM2 is a process manager that keeps your app running in the background even after you close the terminal or the server restarts.
Install PM2 globally: npm install -g pm2
Start your app with PM2: pm2 start npm --name "nextjs-app" -- start
Set PM2 to auto-start on server reboot: pm2 startup pm2 save
Useful PM2 commands to know:
Install Nginx:
sudo apt install nginx
Create a config file for your domain:
sudo nano /etc/nginx/sites-available/yourdomain.com
Add this configuration:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
location / {
proxy_pass http://localhost:3000;
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 the config:
sudo ln -s /etc/nginx/sites-available/yourdomain.com
/etc/nginx/sites-enabled/
Restart Nginx:
sudo systemctl restart nginx
Add Free SSL with Certbot:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Your Next.js app is now live with HTTPS!
Your app is now running on port 3000. The next step is connecting it to your domain name and securing it with HTTPS using a free SSL certificate.
5.1 Install Nginx
sudo apt install nginx -y sudo systemctl start nginx sudo systemctl enable nginx
5.2 Create Nginx Config for Your Domain
sudo nano /etc/nginx/sites-available/yourdomain.com
Paste this configuration — this is the standard template used for Next.js deployments:
server { listen 80; server_name yourdomain.com www.yourdomain.com;
location / {
proxy_pass http://localhost:3000;
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;
}
}
Save and exit: Ctrl+X, then Y, then Enter
5.3 Enable the Configuration
sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
Test your Nginx configuration for errors: sudo nginx -t
You should see: configuration file /etc/nginx/nginx.conf test is successful
Restart Nginx: sudo systemctl restart nginx
Your app should now load at: http://yourdomain.com
5.4 Add Free SSL with Certbot
HTTPS is essential for security and is also a Google ranking signal. Certbot makes it free and automatic.
Install Certbot: sudo apt install certbot python3-certbot-nginx -y
Generate and install your SSL certificate: sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Follow the on-screen prompts. Certbot will automatically configure HTTPS for your domain.
Your Next.js app is now live and secured at: https://yourdomain.com
5.5 Verify SSL Auto-Renewal
Certbot certificates expire every 90 days but auto-renew automatically. Always verify this works: sudo certbot renew --dry-run
Important note: Keep port 80 open on your Vultr firewall at all times — even after SSL is set up. Certbot needs port 80 open to renew certificates automatically. If port 80 is blocked, your SSL will expire silently.
sudo apt install nginx -y
sudo nano /etc/nginx/sites-available/yourdomain.com
sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
sudo certbot renew --dry-run
If you have followed every step in this guide, your Next.js application is now:
✓ Running on a Vultr cloud server ✓ Managed by PM2 — stays online 24/7 ✓ Accessible via your custom domain ✓ Secured with free HTTPS via Certbot
6.1 Quick Recap
Here is a summary of everything we covered:
6.2 Keeping Your App Updated
Every time you push new code, here is how to update your live app on the server:
cd your-nextjs-project git pull origin main npm install npm run build pm2 restart nextjs-app
6.3 Key Things to Remember
Based on thorough research and documentation review, here are the most important things to keep in mind:
6.4 Final Thoughts
This guide was prepared as a clear, honest, and up-to-date reference for deploying Next.js to Vultr cloud servers. Every command has been verified against current official documentation as of April 2026.
Cloud deployment gives your Next.js app the reliability, speed, and security it needs to serve real users professionally — without being locked into any platform.
If you have questions about your deployment or need help setting up your cloud infrastructure, feel free to reach out to us at cloudhousetechnologies.com — our team is always happy to help.
cd your-nextjs-project
git pull origin main
npm install
npm run build
pm2 restart nextjs-appShare this article
Loading comments...
© 2026 CloudHouse Technologies Pvt.Ltd. All rights reserved.