Blog

Tutorials, guides and product news.

Developers

Hosting Next.js on your own server with deploys on git push

2 November 2026 5 min read
Share this post

The short way to host Next.js on your own server is to install a deployment panel such as Coolify and connect your GitHub repository. After that, every git push builds the app and puts the new version live over HTTPS. According to the Next.js documentation, all features work when you deploy with a Node.js server or a Docker container, so you are not tied to any special platform.

Which features work on your own server?

The table in the official documentation is short: a Node.js server and Docker support every feature, and static export is limited. On a single server, this is what it means in practice:

  • Server components, API routes and streaming responses work with next start.
  • next/image needs no extra setup, and images are processed on the server.
  • Caching and incremental static regeneration (ISR) work by themselves on one server with a persistent disk. If you run several copies, you have to share the cache between them.
  • The official recommendation is to put a reverse proxy in front instead of exposing Next.js directly. Coolify comes with Traefik for this, and Traefik also gets the certificate.

How powerful should the server be?

The build decides how much memory you need, not the running app. next build peaks, and the app needs far less once it is up. Coolify itself also uses memory. These are the values we measured on real servers:

SizeSmall projectProject with many packages
2 GB, 1 vCPU350 s, 1.4 GB memory and 0.5 GB swapThe build ran out of memory
4 GB, 2 vCPU213 s, 2.2 GB memory and 0.2 GB swap223 s, 3.5 GB memory and 0.9 GB swap

The small project was Coolify's example Next.js app. The larger one was an AI chat app written with Next.js 16 and about 85 packages, and on 2 GB it ran out of memory during the TypeScript check. The server had 2 GB of swap, and the figures show the highest point. Disk use after the first build was 13-18 GB. These are our own measurements, and your project will differ. If a build fails for lack of memory, scale up first, and scale back down later if you can.

Step by step

1. Connect the repository

Sign in to Coolify, open your project on the Projects page and press New resource. For a public repository, choose Public Git Repository, enter the address and press Check repository.

2. Add a key if the repository is private

In the left menu, go to Private Keys under Keys & Tokens and create a key with Generate ED25519. Add the public key to Deploy keys on the repository's Settings page on GitHub. Then use New resource, choose Private Git Repository (with Deploy Key) and enter [email protected]:user/project.git. Leave Build pack on Railpack, which recognizes Next.js, and the port stays at 3000. Coolify marks Railpack as beta, so choose your own Dockerfile if it gives you trouble.

3. Enter environment variables

On the Environment Variables page, switch to Developer view and paste the contents of your .env file. One detail matters here: variables whose names start with NEXT_PUBLIC_ are written into the code during the build. When you change one, press Redeploy: the panel sees that a build setting changed and builds again. Never give that prefix to a key the browser should not see.

4. Connect your domain

Create an A record at your domain provider that points to the server's IP address. In Coolify, go to the Domains page, press Add domain, choose https as the protocol, enter your domain, save and deploy again. The certificate is requested and renewed automatically. Ports 80 and 443 must be open.

5. Deploy

Press Deploy. The Deployments page shows the build log live. When the build finishes, the old container keeps serving until the new one is ready.

How does git push turn into a deployment?

On every push, GitHub sends the panel a signed request. The panel verifies the signature and rebuilds the app for that branch, and a request with a bad signature is rejected. Here is how you set it up:

  1. On the app's Webhooks page, copy the Webhook URL from the GitHub section, enter a random value of at least 16 characters in Webhook secret and save.
  2. On GitHub, open the repository's Settings, go to Webhooks and press Add webhook.
  3. Put the address in Payload URL and the same value in Secret. Set Content type to application/json and leave push as the only event.

To try it:

git commit --allow-empty -m "deploy test"

git push

The new build appears on the Deployments page. On the small example project, a new commit went live in 41 seconds thanks to the build cache. GitHub must be able to reach the panel's address, and since the panel is installed with a public HTTPS address, nothing extra is needed.

Common errors

SymptomCauseFix
The build dies with Killed or heap out of memoryNot enough memoryScale the server up
A new NEXT_PUBLIC_ value does not showThe value is baked into the buildUse Redeploy
The build fails on a missing variableThe code reads the variable during the buildAdd it in the panel and keep it available at build time
No certificate arrivesThe A record is wrong or has not propagatedCheck the record and deploy again once it has
A 502 error on the live siteThe app listens on a different portCorrect the port on the General page

With the Next.js option at Seturack, Coolify arrives installed: the local server is validated, the welcome wizard is out of the way and the panel opens over HTTPS. The address and password appear in your panel, and you start by connecting GitHub. You have root access, and you can manage everything from the panel if you prefer. Daily backups are included in the price and traffic is unlimited. You set the size with sliders on the Next.js VPS page.

Ready-made on Seturack: Next.js, Coolify.

Comments0

No Comments Yet

Be the first to share your thoughts.

Join the Discussion

Please sign in or sign up to leave a comment.

Never Miss a Post

Get our latest tutorials, guides and product news in your inbox.

You're subscribed to our newsletter.