Alle Anleitungen
Deployment

Deploy your app with Coolify: Git, domain and HTTPS

Connect a GitHub repo, add a Postgres database, set environment variables and get automatic HTTPS and deploys on every push.

Von AI Workspace Team

2 Min. Lesezeit

With Coolify installed on your VPS, deploying an app takes a few clicks. This guide uses a Next.js app with Postgres, but the same steps work for Node, Python, Go, PHP or anything with a Dockerfile.

1. Connect GitHub

In Coolify, go to Sources and add a GitHub App. Coolify walks you through creating it on GitHub; install it on the repositories you want to deploy. Private repos work, and every push can trigger a deploy.

2. Create a project and add the app

  1. Projects → Add — for example my-saas. Each project has environments (production by default).
  2. In the environment, choose + New → Private Repository (with GitHub App) and pick your repo and branch.
  3. Choose a build pack:
    • Nixpacks detects most stacks automatically — the quickest start.
    • Dockerfile if your repo has one. You get the exact same image locally and in production, which we recommend for anything serious.
  4. Set Ports Exposes to the port your app listens on (3000 for Next.js).

3. Add a database

Choose + New → PostgreSQL in the same environment. Coolify starts it on an internal Docker network and shows connection URLs. Use the internal URL in your app — the database never needs a public port.

Then turn on scheduled backups for it under the database's Backups tab.

4. Set environment variables

In the app's Environment Variables tab, add everything your app reads, for example:

DATABASE_URL=postgres://user:password@postgres-internal-host:5432/app
NODE_ENV=production
AUTH_SECRET=generate-a-long-random-value

Mark variables your build needs (like NEXT_PUBLIC_* in Next.js) as build variables — they're baked into the bundle at build time.

5. Run migrations before each deploy

Under the app's configuration, set a pre-deployment command such as:

npx prisma migrate deploy

It runs in the new container before traffic switches over, so the schema is always ready for the code that needs it.

6. Add your domain

  1. At your DNS provider, create an A record: app.example.com → YOUR_SERVER_IP.
  2. In the app's Domains field, enter https://app.example.com.

Coolify's proxy requests a Let's Encrypt certificate automatically. Keep port 80 open — certificate checks use it.

7. Deploy

Press Deploy and watch the build log. When it finishes, open your domain. From now on, every push to the branch redeploys automatically.

Troubleshooting

  • 502 / Bad Gateway — the app isn't listening on the exposed port, or it listens on localhost only. Bind to 0.0.0.0.
  • Build runs out of memory — add swap, upgrade RAM, or build images in CI and deploy the image instead.
  • Certificate never issues — check the A record points at the server and port 80 is open.
  • App can't reach the database — use the internal URL, and make sure both resources are in the same environment.

Next step

Before you share the link, go through the production launch checklist.

Bau deine nächste App mit allen Agenten gleichzeitig

Planen, bauen, prüfen und deployen — alles in einem Arbeitsbereich.

Deviloop holen