DEV Community

Usama Habib
Usama Habib

Posted on • Originally published at osamahabib.com

How to Deploy a Next.js + Prisma + PostgreSQL App on a VPS (Complete 2026 Guide)

Most Next.js tutorials end at npm run dev and say "push to Vercel".
That works — until you need to own your infrastructure and self-host your database.

This guide covers the full path: Next.js + Prisma + PostgreSQL on a real
Ubuntu VPS, behind Nginx, managed by PM2, with free SSL and automated
GitHub Actions deployments.

What you will have by the end

  • Next.js running on your own VPS
  • PostgreSQL self-hosted — no Neon, no Supabase
  • Nginx + free SSL via Let's Encrypt
  • PM2 for process management
  • Auto-deploy on every git push

The one gotcha most guides miss

On PostgreSQL 15+, Prisma migrations fail with permission denied for schema public
unless you explicitly grant schema rights:

\c your_db_name
GRANT ALL ON SCHEMA public TO your_db_user;
Enter fullscreen mode Exit fullscreen mode

📖 Read the complete step-by-step guide (all 15 steps with every command and config):

👉 How to Deploy Next.js + Prisma + PostgreSQL on a VPS — osamahabib.com

Top comments (0)