HomeServicesProjectsBlogFAQStart your project →
Guide ·

How to Deploy a Next.js App and API with Coolify on Your Own VPS

A practical guide to deploying a Next.js frontend and a Node.js API with Coolify, Docker and Cloudflare on a single VPS.

By Ritesh Singh, full-stack developer

Why self-host with Coolify

Managed platforms are convenient, but costs climb as soon as you add a backend, a database and several environments. Coolify gives you push-to-deploy on a VPS you control, using Docker under the hood.

1. Prepare the server

Start with a fresh Ubuntu VPS with at least 2 GB of RAM. Point a domain at it through Cloudflare, and keep the proxy off (grey cloud) until SSL is issued.

2. Install Coolify

Install Coolify with its official install script, open the dashboard on port 8000, create your admin account, and connect your GitHub account or add a deploy key for private repositories.

3. Deploy the Next.js frontend

Create a new resource from your repository and choose the Nixpacks or Dockerfile build pack. Set the port to 3000, add environment variables such as NEXT_PUBLIC_API_URL, and attach your domain. Coolify requests the SSL certificate for you.

4. Deploy the API as a separate service

Keep the backend in its own repository or folder and deploy it as a second resource on an api subdomain. Add your database credentials as environment variables, never in the code.

5. Wildcard subdomains for multi-tenant apps

If every customer needs their own subdomain, add a wildcard DNS record in Cloudflare and configure the wildcard domain on the frontend resource. Read the subdomain in your app to load the right tenant.

Common problems

Builds failing on memory usually mean the VPS is too small or needs swap. A 502 after deploy usually means the app listens on a different port than the one configured. SSL errors usually mean the Cloudflare proxy was on before the certificate was issued.

Need this set up for your product? I do this regularly for clients and can have your app live on your own server.

Related services

Hire me for this

Want this done for your product?

Start your project →