32blogby Studio Mitsu

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.

by omitsu10 min read
CoolifyVPSNext.jsself-hostingVercel Alternative

This article contains affiliate links.

On this page

Coolify is an open-source PaaS that gives you the same "git push → auto-deploy" experience as Vercel — on your own VPS, starting at $4–5/month with zero usage-based charges.

Vercel Pro costs $20/seat/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 workflow on a fixed-cost VPS. No bandwidth limits, no surprise 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 Stars52,000+
LicenseApache 2.0 (free, commercial use allowed)
Current Versionv4 (v5 rewrite in early development)
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. The official docs are thorough and the community is active on Discord.


Cost Comparison: Vercel Pro vs. Coolify + VPS

Vercel ProCoolify + VPS
Monthly Base$20/seat$4–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

Per the official installation docs:

ResourceMinimumRecommended
CPU2 cores2+ cores
RAM2GB4GB+
Disk20GB+50GB+
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:

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. If you want to test-drive the setup, Kamatera's 30-day free trial lets you try Coolify without upfront cost.


FAQ

Is Coolify really free?

Yes. Coolify is Apache 2.0 licensed — free for both personal and commercial use. You only pay for the VPS itself. There's also a Coolify Cloud managed option if you don't want to self-host Coolify itself.

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

Absolutely. Coolify manages multiple apps via Docker containers on the same server. A 4GB RAM VPS comfortably runs 2–3 Next.js apps with a database. Coolify's dashboard lets you manage them all from one UI.

Does next/image optimization work on Coolify?

It works, but you need to install sharp as a dependency in your project. On Vercel, next/image uses a built-in optimization loader. On Coolify, Next.js falls back to the sharp library. Run npm install sharp and set images.remotePatterns in next.config.js if you load external images.

How do I handle HTTPS/SSL on Coolify?

Coolify integrates with Let's Encrypt automatically. When you add a custom domain in the Domains section, Coolify's built-in Traefik reverse proxy requests and provisions a certificate. Renewal is automatic — no manual intervention needed.

Can I migrate from Vercel to Coolify without downtime?

Yes, with a DNS-based cutover. Deploy your app on Coolify first, verify it works, then update your DNS A record to point to the VPS IP. DNS propagation typically completes within minutes to a few hours. During propagation, some users hit Vercel while others hit Coolify — both serve the same app, so there's no downtime.

Is Coolify stable enough for production?

Coolify v4 has been in active use since 2024 and receives regular updates (latest: v4.0.0-beta.470). The "beta" label is misleading — v4 is stable for production use. A v5 rewrite is underway but hasn't affected v4 maintenance. The community on GitHub (52,000+ stars) and Discord is responsive.

What about backups?

Coolify supports scheduled database backups to S3-compatible storage. For app data and volumes, you'll need to set up your own backup strategy — VPS-level snapshots from your provider work well for full-server recovery.


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.

Related articles:

Kamatera

Enterprise-grade cloud VPS with global data centers

  • 13 data centers (US, EU, Asia, Middle East)
  • Starting at $4/month for 1GB RAM — pay-as-you-go
  • 30-day free trial available