You can run a production Next.js application on an $18 VPS with Coolify, and the first deployment takes about 45 minutes. Coolify 4.6.0, the stable release listed on November 6, 2026, installs with one command, pulls the repository from GitHub, builds the image and routes your domain with a Let's Encrypt certificate. Next.js 16.4.5 is the version published on npm on the same date; the method also works for an app still on Next.js 15.
The server is the real cost. Coolify asks for 2 CPU cores, 2 GB of RAM and 10 GB of disk. A DigitalOcean droplet with 2 vCPUs, 2 GB of RAM and 60 GB of SSD costs $18 per month; the 4 GB version costs $24. Hetzner's CPX22 offers 2 AMD vCPUs, 4 GB of RAM, 80 GB of NVMe and 20 TB of traffic for €19.99 excluding VAT per month. Add backups, and you land around $21.60 or €21.20 per month before the domain. If you run a single app and do not want to patch a server, Vercel Pro at $20 per month is still the shorter path; our Vercel vs Cloudflare vs Coolify comparison works through the numbers.
This guide uses the most reproducible route: a multi-stage Dockerfile with output: "standalone". Coolify can also detect Next.js with Nixpacks, and that option is included for a quick first test. Prices, versions and limits were checked on November 6, 2026.
What you need before touching the server#
Start from a fresh Ubuntu 24.04 LTS image with SSH key access and a root or sudo user. Coolify supports Debian, Ubuntu, AlmaLinux, Rocky Linux and other Linux distributions, but Ubuntu LTS is the best-documented path. Avoid a server that already runs other applications: the installer sets up Docker, creates directories under /data/coolify and starts its own containers.
You also need a domain, a GitHub repository with the app, and a build that works locally. Run npm ci and npm run build on your machine first. A failed build on the VPS is slower to debug, and Coolify's deployment log moves quickly.
Open only the ports you need. Port 22 is for SSH, 80 and 443 are for the proxy and certificates, and 8000 is for the Coolify dashboard during installation. Port 8000 gets closed later.
ssh [email protected]
apt update && apt upgrade -y
apt install -y ufw curl
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 8000/tcp
ufw enable
ufw statusCheck that Docker was not installed through snap; Coolify's documentation advises against it. If docker --version points to a snap package, remove it and let the installer add Docker Engine, or follow the official Docker installation guide for Ubuntu.
Install Coolify and claim the admin account#
One command is enough on a fresh server. The script installs the required packages, Docker Engine, prepares /data/coolify, configures the directories and starts Coolify.
curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bashThe dashboard then answers on http://203.0.113.10:8000. Create the admin account immediately: Coolify's documentation warns that the first person to reach the registration page becomes the instance administrator and gains root access to the server. Do not leave that page open on the public internet while you make coffee.
Back up /data/coolify/source/.env off the server, in a password manager or an encrypted archive. It contains APP_KEY, the key that encrypts values stored by Coolify. Without it, restoring the instance is incomplete even if you backed up every application database. This is the first self-hosting trap: people back up project data and forget the platform secrets.
Give the dashboard a domain#
Coolify can serve its own panel over HTTPS. Create an A record for coolify.example.com pointing to the VPS, then open Settings > General and set the URL to https://coolify.example.com. Coolify reloads its proxy and requests the certificate. Confirm that https://coolify.example.com answers before closing port 8000.
dig +short coolify.example.com A
curl -I https://coolify.example.com
ufw delete allow 8000/tcpKeep port 22 open. If you do not want to configure the dashboard domain yet, restrict port 8000 to your own address instead of exposing it to everyone:
ufw delete allow 8000/tcp
ufw allow from 198.51.100.7 to any port 8000 proto tcpThat rule is a temporary safeguard. A panel reachable over HTTP at http://IP:8000 exposes your environment variables, databases and containers to anyone who knows the address.
Build a standalone Next.js image#
The official Next.js Dockerfile expects standalone output. Enable it in next.config.ts so that next build produces a minimal server with only the required files:
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
output: "standalone",
};
export default nextConfig;Without this option, .next/standalone does not exist and the Dockerfile below fails at the COPY step. Standalone output copies the dependencies that are actually used, but not public or .next/static: the Dockerfile must copy those itself. The Next.js output documentation describes the behavior.
Create a Dockerfile at the repository root. This version follows the three stages of the official Docker example, using npm and Node.js 24.13.0:
ARG NODE_VERSION=24.13.0-slim
FROM node:${NODE_VERSION} AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
FROM node:${NODE_VERSION} AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
FROM node:${NODE_VERSION} AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/public ./public
RUN mkdir .next && chown node:node .next
COPY --from=builder --chown=node:node /app/.next/standalone ./
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
USER node
EXPOSE 3000
CMD ["node", "server.js"]Three details save hours. HOSTNAME=0.0.0.0 makes the server listen on every interface; a process bound to 127.0.0.1 is invisible to the Coolify proxy. curl is installed in the final image so Coolify's HTTP health check can run: the node:slim image does not include it. And npm ci requires a committed package-lock.json; if the repository uses pnpm or yarn, adapt the install command.
Add a .dockerignore so the Docker daemon does not receive unnecessary files:
node_modules
.next
.git
.env*Test the build locally before pushing:
npm ci
npm run build
npm run start
curl -I http://127.0.0.1:3000Create the application in Coolify#
In Coolify, create a project, then select + New. For a private repository, configure a GitHub App source under Sources > New source > GitHub App and let Coolify register the GitHub app automatically. For a public repository, paste its HTTPS URL. The GitHub App documentation covers permissions and installation.
Choose the instance's localhost server, the main branch and the build pack. Two routes work:
- Nixpacks detects Next.js, runs
npm run buildand starts the server. It is the fastest way to test the repository and the domain. Check the detected commands under General and keep the internal port at3000. - Dockerfile builds the image from the file above. Set Base Directory to
/, Dockerfile Location to/Dockerfile, and Ports Exposes to3000. The result is more predictable, and the final image does not contain the build toolchain.
For a production app, use the Dockerfile. Nixpacks is useful for validating the repository and domain in minutes, but it depends on automatic detection and the versions chosen by the builder.
Before the first deployment, add environment variables under Environment Variables. A NEXT_PUBLIC_* variable is inlined into the JavaScript bundle during the build: if you change it, redeploy instead of restarting. A server variable such as DATABASE_URL can stay at runtime. The Coolify environment variable documentation separates the two scopes and lets you remove a value from the build.
DATABASE_URL=postgresql://app:password@db:5432/app
AUTH_SECRET=replace-with-a-long-secret
NEXT_PUBLIC_APP_URL=https://app.example.comFor the database, there are two common choices. A PostgreSQL service created inside Coolify runs on the same VPS and provides an internal URL; it is the simplest option for a solo project, as long as you configure its backups. A managed external database, such as Neon, Supabase or a PostgreSQL instance from another provider, moves backups and upgrades elsewhere. In both cases, keep the password in Coolify's variables, not in the image.
Migrations need their own step. Coolify's pre-deployment command runs inside the container that is currently serving traffic, before it is replaced, and it is skipped on the first deployment. For a Prisma app, run the first migration in the container terminal after startup, then add npx prisma migrate deploy as a pre-deployment command for later releases. Make sure the migration is compatible with the old version while both containers can run side by side.
DNS, domain, and HTTPS#
Create the application's DNS record, for example app.example.com as an A record pointing to the VPS address. Wait until resolution is correct before requesting the certificate:
dig +short app.example.com AIn Coolify, open the application, then Domains > Add domain. Choose https, enter app.example.com, and leave the internal port at 3000 or set it explicitly. Redeploy or restart so the proxy picks up the new route. Coolify then requests a Let's Encrypt certificate and renews it automatically.
Generated sslip.io domains are useful for a test, but they stay on HTTP: Let's Encrypt rate-limits the shared sslip.io zone, and HTTPS issuance often fails there. Use your own domain for production. If a CDN or another proxy sits in front of the server, confirm that ports 80 and 443 reach the Coolify proxy, otherwise certificate validation fails.
Deploy and confirm it works#
Select Deploy and follow the logs. The first build takes a few minutes: npm installs dependencies, Next.js compiles, Docker assembles the image, then Coolify starts the container and updates the proxy. Once the deployment finishes, test the domain and a health endpoint:
curl -I https://app.example.com
curl -fsS https://app.example.com/api/healthAdd a lightweight health route if the app does not have one. It should not touch the database or write data:
export function GET() {
return Response.json({ ok: true });
}Under Healthcheck, choose HTTP, path /api/health, port 3000, a 30-second interval, a 5-second timeout and 3 retries. A 20-second start period gives the Next.js server time to boot. Coolify's HTTP check runs from inside the container: without curl or wget in the final image, Docker marks the container unhealthy and Traefik may return No available server.
First-deployment errors are usually repetitive. No available server or a 502 means the exposed port does not match the listening port, the process listens on 127.0.0.1 instead of 0.0.0.0, or the Coolify proxy is stopped. A missing certificate comes from incorrect DNS, a closed port 80 or a broken AAAA record. A killed build comes from memory pressure. Those three checks fix most cases.
Push-to-deploy, rollbacks, and rolling updates#
With a GitHub App, open Advanced > Deployment and select Deploy on push (webhooks). A push to the configured branch starts a deployment, and the logs show the commit. For a public repository or a deploy key, Coolify does not receive GitHub events: create a manual webhook with the URL and secret shown under Webhooks, then enable the push event.
If tests run in GitHub Actions, keep Coolify on manual deployment and call the webhook after the tests. Store the token in the repository secrets:
curl --fail --request POST "$COOLIFY_WEBHOOK" \
--header "Authorization: Bearer $COOLIFY_TOKEN"Coolify keeps images from previous deployments and offers a rollback under Rollback. Set Images to keep high enough to cover a bad release. A rollback does not restore the database or persistent volumes: if the new version ran a destructive migration, switching back to the previous image is not enough. Keep migrations backward compatible and take a backup before every schema change.
Rolling updates work for Nixpacks, Railpack, Dockerfile and Docker Image applications: Coolify starts the new container, waits for the health check, then stops the old one. This is not a zero-downtime guarantee. A port published on the host, a fixed container name, or an app that does not shut down gracefully prevents the overlap. Configure the Stop Grace Period and test a deployment under real traffic before relying on it.
Backups and day-two operations#
Back up three separate things: the Coolify configuration, the application database and persistent files. /data/coolify/source/.env holds the instance key; an off-server copy prevents losing your secrets when the disk fails. Coolify database backups support PostgreSQL, MySQL, MariaDB, MongoDB, ClickHouse and SQLite, write to /data/coolify/backups and can upload to S3 storage. Set a schedule and a retention policy, then verify that a restore works against a disposable database. The backup documentation makes the point directly: a file that was created is not a tested backup.
A provider snapshot is not a logical dump. The snapshot captures the disk at one moment; if you delete a row at 2 p.m., last night's snapshot does not save you. Hetzner's automatic backups start at €1.1980 excluding VAT per month with seven slots. DigitalOcean charges 20% of the droplet price for weekly backups or 30% for daily backups. For an $18 droplet, that is $21.60 or $23.40 per month before the domain.
On the system side, enable automatic security updates, watch disk space and inspect Docker logs. docker system df shows images and volumes that take space; df -h shows the server disk; docker stats --no-stream gives memory and CPU per container. Update Coolify from the panel or with the update procedure in the documentation, and read the release notes before clicking. An instance left untouched for six months may contain a vulnerability that has already been fixed.
Finally, monitor the app from outside. A monitor that requests https://app.example.com/api/health every five minutes tells you about a stale certificate or a stopped container before your users do. A self-hosted VPS is not a SaaS product: certificates, updates, backups and restores are part of the price.
Failures that cost an afternoon#
- The build dies without a clear message. Memory is the usual cause. Add swap, reduce the build size or use a separate build server.
- The domain returns a 502. Check the exposed port, the
0.0.0.0binding and the Coolify proxy status.docker psand the runtime logs point to the answer. - The certificate never arrives. DNS must point to the right server, ports 80 and 443 must be open, and a broken
AAAArecord can block validation even when IPv4 works. - Assets are missing after switching to standalone.
publicand.next/staticwere not copied into the image. The Dockerfile must copy them explicitly. - A
NEXT_PUBLIC_*variable stays empty. It is fixed at build time. Change it and redeploy; a restart does not inject a new value. - The container is unhealthy. The HTTP health check needs
curlorwgetin the final image and must target the internal port, not the public one. - The rollback does not fix the database. A previous image does not undo a migration. Restore the database separately if the schema changed.
When a managed platform is the better call#
If you deploy one Next.js app with no database and no internal tools, and you do not want to patch a server, Vercel Pro at $20 per month remains the shortest route. Branch previews, rollbacks and certificates are included, and you do not manage Docker. Our Vercel vs Cloudflare vs Coolify comparison puts numbers on that choice.
Coolify starts to make sense when you consolidate several services on one machine: an app, a PostgreSQL database, a wiki, an analytics tool and an internal utility. The cost per application drops, and the data stays with your provider. If you are choosing between self-hosted platforms, our Coolify vs Dokploy vs CapRover comparison lists the RAM requirements and the features of each. For a first service to run next to Next.js, the Docmost Docker Compose tutorial shows how an app and its database fit on a VPS.
Frequently asked questions
How much RAM does Coolify need for a Next.js app?
Coolify's documentation asks for 2 CPU cores, 2 GB of RAM and 10 GB of disk. For a Next.js app and a PostgreSQL database on the same machine, 4 GB is more comfortable, especially during builds. On 2 GB, watch memory and add swap if the build is killed.
Is Coolify free?
Self-hosting is free, with no feature restrictions. Coolify Cloud costs $5 per month for two connected servers, then $3 per month per additional server; it runs the panel on the vendor's infrastructure, not your applications. The VPS, backups and your time are still your cost.
Should I use Nixpacks or a Dockerfile for Next.js?
Nixpacks detects Next.js and deploys faster for a first test. A multi-stage Dockerfile with output: "standalone" gives a more predictable, smaller image and does not depend on the builder's chosen versions. Use the Dockerfile for production.
How do I update the application?
A push to the configured branch triggers a deployment when auto-deploy is enabled. Otherwise, select Deploy or Redeploy. Database migrations are not automatic: run them in a separate step and keep a backup before every schema change.
Where are backups stored?
Coolify database backups are written to /data/coolify/backups on the server and can be copied to S3 storage. Back up /data/coolify/source/.env off the server as well. Test a restore against a disposable database: a file you never restored proves nothing.
Is HTTPS automatic?
Yes, if you add a domain as https:// in Coolify and its DNS record points to the server. Ports 80 and 443 must be open for Let's Encrypt to validate the domain. sslip.io test domains stay on HTTP and are not suitable for production.
Sources#
Official pages consulted on November 6, 2026. Prices checked in November 2026, excluding taxes where marked.
- Coolify — self-hosted installation
- Coolify — pricing
- Coolify — deploy your first app
- Coolify — environment variables
- Coolify — domains
- Coolify — DNS
- Coolify — health checks
- Coolify — database backups
- Coolify — database restore
- Coolify — rolling updates
- Coolify — rollbacks
- Coolify — GitHub App
- Coolify — Nixpacks
- Coolify — Dockerfile
- Coolify — stable versions
- coollabsio/coolify GitHub repository
- Next.js — self-hosting
- Next.js — output standalone
- Next.js — official Docker example
- Next.js — published npm version
- Vercel — pricing
- Docker — install on Ubuntu
- Hetzner — Regular Performance cloud
- DigitalOcean — Droplet pricing



Comments
Loading comments…