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.
2 min read
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
- Projects → Add — for example
my-saas. Each project has environments (productionby default). - In the environment, choose + New → Private Repository (with GitHub App) and pick your repo and branch.
- 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.
- Set Ports Exposes to the port your app listens on (
3000for 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
- At your DNS provider, create an A record:
app.example.com→YOUR_SERVER_IP. - 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
localhostonly. Bind to0.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.