How to Deploy Next.js to Cloud Servers: A Step-by-Step Guide

Sanjai

Junior DevOps Engineer

Last Updated: 26 September 2026
How to Deploy Next.js to Cloud Servers: A Step-by-Step Guide
🖥️12,400+PCs Fixed
⭐4.9★Google Rating
⚡<15 minAvg. Response
🛡️ISO 27001Certified

Who I Am and Why I Wrote This

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:

  1. Too brief — they skipped important steps
  2. Too outdated — using older Node.js versions or deprecated commands
  3. Too generic — not specific to Vultr's setup

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. Every command is verified against current documentation as of April 2026
  2. It covers the full journey — from a blank server to a live HTTPS domain
  3. It includes the steps most tutorials skip — like environment variables and PM2 auto-restart
  4. Server specs are flexible — we follow client requirements for Vultr plan and region selection

1.3 Who This Guide Is For

  1. Developers deploying Next.js for the first time
  2. Teams moving away from Vercel to self-hosted servers
  3. Anyone who wants full control over their deployment
  4. DevOps beginners learning server management on Vultr

1.4 Tools and Stack Used

  1. Cloud Provider: Vultr (plan and region as per client requirements)
  2. OS: Ubuntu 22.04 LTS
  3. Runtime: Node.js 18 LTS
  4. Process Manager: PM2
  5. Web Server: Nginx
  6. SSL: Certbot with Let's Encrypt (free)

Last updated: April 2026 — reflects current Node.js LTS, latest Certbot commands, and modern Nginx configuration best practices.

What is Next.js and Why Deploy to Vultr?

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:

  1. Server-Side Rendering (SSR) — pages are rendered on the server for better SEO and faster load times
  2. Static Site Generation (SSG) — pages are pre-built at build time for maximum performance
  3. API Routes — build backend APIs inside the same Next.js project without a separate server
  4. Image Optimisation — automatic compression and lazy loading built in by default

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:

  1. Cost at Scale • Vercel's free tier has strict bandwidth limits • Costs increase quickly for high-traffic production applications

  2. Limited Server Control • You cannot customise the server environment • Some enterprise features require expensive plans

  3. 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:

  1. Flexible Plans • Multiple server sizes to match any client budget • Scale up or down based on project requirements

  2. Global Data Centres • Locations across Asia, Europe, and the Americas • Choose the region closest to your users for best performance

  3. Simple Control Panel • Easy to set up and manage even for beginners • One-click OS installation with Ubuntu 22.04 LTS

  4. Reliable Performance • High-frequency NVMe SSD storage • Consistent uptime for production applications

  5. Transparent Pricing • No hidden fees • Pay only for what you use

Prerequisites — What You Need Before Starting

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

  1. A working Next.js project on your local machine
  2. Your project pushed to a GitHub repository
  3. A .env.production file with all your environment variables properly configured
  4. Node.js and npm installed locally

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

  1. A Vultr cloud server running Ubuntu 22.04 LTS
  2. Server plan selected based on your client's traffic and performance requirements
  3. Server region selected based on your client's target audience location
  4. Root SSH access to the server

Recommended minimum specs for a basic Next.js app:

  1. RAM: 1GB minimum (2GB recommended for production)
  2. Storage: 25GB SSD minimum
  3. CPU: 1 vCPU minimum

3.3 Networking Requirements

Make sure these ports are open in your Vultr server firewall:

  1. Port 22 — SSH access
  2. Port 80 — HTTP traffic 3, Port 443 — HTTPS traffic

3.4 Optional but Strongly Recommended

  1. A registered domain name (e.g. yourdomain.com)
  2. DNS A record pointing to your Vultr server IP
  3. www subdomain also pointing to the same IP

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

Step-by-Step Deployment Process

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:

  • pm2 status — check if your app is running
  • pm2 logs — view live application logs
  • pm2 restart nextjs-app — restart after updates
  • pm2 stop nextjs-app — stop the app
  • pm2 monit — real-time monitoring dashboard
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!

Setting Up Nginx and SSL for Your Domain

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

Conclusion

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:

  1. Who I am — Sanjay, Junior DevOps Engineer at CloudHouse, who researched and documented this guide as a reliable deployment reference
  2. What Next.js is and why Vultr is a great self-hosted alternative to Vercel
  3. What to prepare before starting — especially the .env file which most tutorials skip
  4. Full step-by-step deployment with verified, copy-ready commands
  5. Nginx configuration to connect your domain
  6. Free SSL with Certbot for HTTPS security

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:

  1. Always test your production build locally first before deploying to the server
  2. Never skip creating the .env.production file on the server before building 3, Always keep port 80 open for SSL auto-renewal
  3. Use pm2 monit to monitor your app in real time
  4. Choose your Vultr plan and region based on your client's traffic needs and audience location

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-app
next.jscloud deployment

Get the Free Cloud Infrastructure Checklist (PDF)

Deploy, secure, and optimise cloud servers the right way — a practical checklist for every new project.

Cloud costs and complexity getting out of hand?

Our Cloud Management service optimises your AWS, GCP, or Azure environment — cutting costs, improving reliability, and handling day-to-day operations.

  • Cloud cost optimisation and right-sizing
  • Multi-cloud monitoring and alerting
  • Security hardening and compliance checks
  • 24×7 cloud operations support
See Pricing Plans →

What our customers say

“CloudHouse cut our AWS bill by 34% in the first month just by right-sizing our instances. Should have called them sooner.”

Ravi T.

Head of Engineering

“GCP setup was a disaster before CloudHouse. They sorted networking, IAM, and billing in one week.”

Anjali S.

Cloud Architect

Frequently Asked Questions

Yes — 90% of fixes are done over a secure remote session in 15–30 minutes. Our technicians connect safely using industry-standard tools.

Need this done for you?

Website Development

Fast, SEO-ready websites built to generate enquiries.

Learn more

Book your free 15-minute diagnosis

A certified technician will call you back within 15 minutes during business hours.

Share this article

Leave a Comment

Comments (0)

Loading comments...