32blogby StudioMitsu
vercel8 min read

Self-Host Next.js with Coolify on a VPS — Full Guide

Tired of Vercel's usage-based billing? Deploy Next.js on a $5/month VPS with Coolify. Step-by-step from installation to production deployment.

CoolifyVPSNext.jsSelf-hostingVercel Alternative
On this page

Vercel Pro costs $20/month, but bandwidth overages and Function Invocations can push your bill much higher. The "git push to deploy" experience is fantastic, but dreading your monthly invoice defeats the purpose.

Coolify gives you the same "git push → auto-deploy" experience on a $5/month VPS. No bandwidth limits, no usage-based charges. This guide walks you through VPS selection, Coolify installation, and deploying a Next.js app — start to finish.


What Is Coolify

Coolify is an open-source PaaS (Platform as a Service). Think of it as "Vercel, but on your own server."

DetailInfo
GitHub Stars51,000+
LicenseApache 2.0 (free, commercial use allowed)
Current Versionv4
CreatorAndras Bacsai

It replicates what Vercel, Netlify, and Heroku do — but on your own hardware. Here's what you get:

  • Git push → auto-build → deploy
  • Preview deployments (temporary environment per PR)
  • Environment variable management via GUI
  • Automatic Let's Encrypt SSL certificates
  • One-click databases: PostgreSQL, Redis, MongoDB, and more
  • Direct Docker Compose deployments

It doesn't cover every Vercel feature, but for "I want to run a Next.js app on my own server," it's more than enough.


Cost Comparison: Vercel Pro vs. Coolify + VPS

Vercel ProCoolify + VPS
Monthly Base$20$5–15 (VPS only)
Bandwidth1TB included, then $0.15/GBUnlimited (depends on VPS plan)
Function Invocations1M included, then $0.60/1MUnlimited
Build Minutes100hrs included, then overageUnlimited
SSL CertificatesAutomaticAutomatic (Let's Encrypt)
CDNGlobal edge networkNone (single server)
ScalingAutomaticManual

The key difference: zero usage-based charges. Your VPS bill is fixed. Traffic spikes don't cost extra. You won't wake up to a surprise invoice because your site went viral.

For details on Vercel's billing mechanics, see our Vercel Spend Management guide.

The tradeoff is clear. Vercel's edge network and auto-scaling are powerful. For globally distributed services, a single VPS can't compete. But for regional sites or projects under 1M monthly pageviews, a VPS handles the load just fine.


Choosing a VPS

Coolify's Minimum Requirements

ResourceMinimumRecommended
CPU2 cores2+ cores
RAM2GB4GB+
Disk30GB50GB+
OSUbuntu 22.04 / 24.04 LTSUbuntu 24.04 LTS

A 2GB plan runs 1–2 Next.js apps comfortably. If you're also running databases on the same server, go with 4GB or more.

Any VPS provider works as long as it meets the minimum specs. Popular choices:

  • Hetzner — Best price-to-performance in Europe. 4GB/2vCPU for €5.49/month.
  • DigitalOcean — $6/month for 1GB. Straightforward UI. Good documentation.
  • Linode (Akamai) — $12/month for 2GB. Solid network performance.
  • Vultr — $12/month for 2GB. 32 global locations.

Choose a server location close to your primary audience. If most of your users are in North America, pick a US region. For Asia-Pacific, Singapore or Tokyo.


Installing Coolify on Your VPS

1. SSH Into Your Server

After provisioning your VPS, you'll get an IP address and root password (or SSH key). Connect from your terminal.

bash
ssh root@YOUR_SERVER_IP

2. Configure the Firewall

Open the ports Coolify needs.

bash
ufw allow 22/tcp    # SSH
ufw allow 80/tcp    # HTTP (Traefik)
ufw allow 443/tcp   # HTTPS (Traefik)
ufw allow 8000/tcp  # Coolify dashboard
ufw allow 6001/tcp  # Coolify Realtime (live updates)
ufw allow 6002/tcp  # Coolify Terminal (web shell)
ufw enable

Ports 8000, 6001, and 6002 are for Coolify's dashboard. Once you set up a custom domain with reverse proxy, you can close these ports.

3. Install Coolify

One command installs everything.

bash
curl -fsSL https://cdn.coollabs.io/coolify/install.sh | sudo bash

This installs Docker, Docker Compose, and Coolify. Takes 2–5 minutes.

4. Access the Dashboard

Open http://YOUR_SERVER_IP:8000 in your browser. The initial setup screen walks you through creating an admin account and configuring the server. Coolify auto-detects the local server — just confirm and you're done.


Deploying a Next.js App

1. Configure next.config.js

For self-hosting, set output: "standalone". This makes Next.js bundle its dependencies into a self-contained build.

js
// next.config.js
const nextConfig = {
  output: "standalone",
};

export default nextConfig;

Without this, the container would need the entire node_modules directory, inflating the image size.

2. Create a Project in Coolify

  1. Coolify dashboard → ProjectsAdd New
  2. New ResourcePublic / Private Repository (with GitHub App)
  3. Set up GitHub integration (install the GitHub App)
  4. Select your repository and branch

Coolify uses Nixpacks to auto-detect the build environment. For a Next.js project, it picks Node.js and runs npm run buildnpm run start automatically. If Nixpacks doesn't work for your setup, you can switch to a Dockerfile build instead.

If Nixpacks fails on Next.js 15+, create a nixpacks.toml in your project root:

toml
# nixpacks.toml
[phases.install]
cmds = ["npm ci --legacy-peer-deps"]

3. Set Environment Variables

In the Environment Variables section, add your production variables — the same ones from your .env.local.

text
DATABASE_URL=postgresql://user:pass@localhost:5432/mydb
NEXT_PUBLIC_SITE_URL=https://example.com

4. Configure Your Domain

Add your custom domain in the Domains section. Coolify automatically provisions a Let's Encrypt certificate.

Point your domain's A record to your VPS IP address in your DNS settings, and you're set.

5. Deploy

Hit Deploy. The first build takes 3–5 minutes since there's no cache. After that, every push to your configured branch triggers an automatic deployment — just like Vercel.


What Coolify Can't Do

Coolify isn't a 1:1 Vercel replacement. These features aren't available:

FeatureVercelCoolify
Edge Functions✅ Runs at edge globally❌ Not available
Global CDN✅ Automatic❌ Single server
Image Optimization✅ Built-in next/image loader⚠️ Configure sharp yourself
Analytics✅ Built-in❌ BYO (Plausible, Umami, etc.)
Preview Deployments✅ Per-PR automatic✅ Per-PR automatic
Web Application Firewall✅ Pro and above❌ BYO (Fail2ban, etc.)

If you need Edge Functions, stick with Vercel. Edge-based auth checks, geo-redirects, and A/B testing don't have easy alternatives on a single VPS.

For CDN, put Cloudflare in front of your VPS. Even Cloudflare's free plan gives you unlimited bandwidth CDN. The combination of VPS + Coolify + Cloudflare gets you close to Vercel's delivery performance for $5–15/month.

For everything else — static sites, SSR blogs, admin dashboards, internal tools — Coolify handles the job.


Wrapping Up

Decision FactorVercelCoolify + VPS
Unpredictable traffic✅ Auto-scaling⚠️ Manual resource management
Fixed monthly cost❌ Usage-based risk✅ Fixed rate
Edge Functions needed✅ Supported❌ Not available
Zero ops preferred✅ Fully managed❌ Self-managed
Regional audience✅ But CDN favors US/EU✅ Choose your server region

Vercel is the best platform for people who want zero infrastructure concerns. But that convenience comes with usage-based billing risk. Make sure you configure Spend Management properly to avoid surprises.

Coolify + VPS is for people willing to spend 30–60 minutes on setup to lock in a fixed monthly cost. Once configured, you get the same git-push-to-deploy workflow at a fraction of the price.

Neither is universally better. Choose based on your project's scale, budget, and your comfort with server management.