DeployWise
HomeGuidesDeploy Next.js to VPS
Next.jsVPSUbuntuPM2Nginx

Deploy Next.js to VPS: Step-by-Step Beginner Guide

Deploy a production-ready Next.js application to any Ubuntu VPS using DeployWise — covers SSH setup, PM2 process management, Nginx reverse proxy and free SSL certificates. No DevOps experience required.

8 min read
Updated 2026

What you need

A VPS running Ubuntu 20.04 or later (DigitalOcean, Hetzner, Vultr, etc.)
SSH access — either password or private key
A GitHub account with your Next.js repo
A domain name (optional, but recommended for SSL)

Why deploy Next.js to a VPS?

Vercel and similar platforms are excellent for prototypes and small projects. But as your app grows, costs can skyrocket — Vercel charges $0.15/GB for bandwidth above 100 GB, and team plans start at $20/month per member.

A $5/month VPS from Hetzner or DigitalOcean can host multiple production Next.js apps with no traffic limits, full SSH access, and complete control over your environment. The tradeoff used to be complexity — but that's what DeployWise solves.

1Set up your VPS

Start with a fresh Ubuntu 22.04 LTS droplet/instance. Make sure SSH is accessible on port 22 (or a custom port). You'll need either a root password or an SSH private key.

Recommended minimum specs for a single Next.js app:

SpecMinimumRecommended
CPU1 vCPU2 vCPU
RAM1 GB2 GB
Storage20 GB SSD40 GB SSD
Monthly cost~$5/mo~$10/mo

2Add your server to DeployWise

Open DeployWise dashboard and sign in with GitHub. Then navigate to Servers → Add Server and fill in:

NameAny label (e.g. "Production VPS")
HostYour server's IP or hostname
Port22 (or your custom SSH port)
Usernameroot or your sudo user
AuthPassword or paste your private key

Click Test Connection. DeployWise will SSH into your server to verify connectivity. If the test passes, save the server.

3Create your project

Go to Projects → New Project. Connect your GitHub account if you haven't already, then configure:

RepositorySelect your Next.js GitHub repo
Branchmain or production — whichever you deploy from
Build commandnpm run build (default, can leave blank)
Start commandnpm start — required for SSR. Leave blank for static export.
Port3000 (Next.js default) or your custom port
DomainOptional — your custom domain for Nginx + SSL setup
Auto DeployEnable to trigger deploys on every git push

4Deploy

Click Deploy Now. DeployWise will execute the following steps on your server automatically:

1.Install Node.js via NVM (if not present)
2.Install PM2 globally
3.Clone your repository via Git
4.Run npm ci to install dependencies
5.Run npm run build
6.Start/restart the app with PM2
7.Configure Nginx reverse proxy
8.Issue Let's Encrypt SSL certificate (if domain configured)

The entire process typically takes 30–90 seconds. You can watch every step live in the deployment log panel.

What happens after deployment

Your app is now:

Running under PM2 — restarts automatically if it crashes
Proxied through Nginx — handles HTTP/HTTPS, gzip, and headers
Protected with SSL — free Let's Encrypt certificate, auto-renewing
Accessible at your domain or via server IP

Future deploys are one click away. If something breaks, roll back to any previous commit from the deployment history.

Common issues

Build fails with 'out of memory'

The Next.js build process can require 1–1.5 GB RAM. If your VPS has only 1 GB, add a 1 GB swap file: sudo fallocate -l 1G /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile

Port 3000 is already in use

Another PM2 process may be occupying the port. Check with: pm2 list — and stop conflicting processes, or change your project's port.

SSL certificate fails

Ensure your domain's A record points to your VPS IP and that port 80 is open in your firewall (ufw allow 80).

Ready to deploy?

Sign in with GitHub, add your VPS, and have your Next.js app live in minutes — for free.

Open DeployWise Dashboard

Frequently Asked Questions

How long does it take to deploy Next.js to a VPS?+

With DeployWise, about 5 minutes. Manually, expect 30-60 minutes for first-time setup including SSH, Node.js, PM2, Nginx, and SSL.

Do I need DevOps experience to deploy to VPS?+

No. This guide walks you through every step. With DeployWise, the entire process is automated — you just connect your GitHub repo and server.

Which VPS provider is best for Next.js?+

Hetzner offers the best price-to-performance ratio. DigitalOcean has the best documentation. Hostinger is the cheapest starting at $4/month. All work great with Next.js.

Can I run multiple Next.js apps on one VPS?+

Yes! A $10/month VPS with 2GB RAM can comfortably run 3-5 Next.js apps using PM2 process management.

Related guides