In short
To deploy automatically from GitHub with Coolify, first set the Coolify panel's domain, then create a GitHub App under Sources and install it on your repositories. Next, add the private repository as a new resource, choose the build method and port, enter your environment variables and put your domain with https in the Domains field. On every push, Coolify rebuilds the app and issues SSL automatically.
In this guide
- Before you start
- Step 1: Prepare your DNS records
- Step 2: Set the Coolify panel's domain
- Step 3: Create a GitHub App and install it on your repositories
- Step 4: Add the repository as an application
- Step 5: Define environment variables
- Step 6: Domain and automatic SSL
- Step 7: First deploy and automatic deploys
- Optional: Pull request previews
- Alternative: Controlled deploys with GitHub Actions
- Rolling back a bad release
- Common problems
- Next step: set up your deploy pipeline
Setting up Coolify GitHub deploys means your app is automatically built and published on your own server every time you git push. The workflow has four parts: connecting a GitHub App to Coolify, adding the repository as an application, defining environment variables, and setting up the domain and SSL. This guide walks through each step in order, along with common mistakes. If you're new to Coolify, start with What is Coolify?
Before you start
- A server with root access and Coolify installed
- A domain name and access to its DNS panel
- A GitHub account and the repository to deploy (private or public)
- Ports 80 and 443 open to the internet on the server
If you don't want to deal with preparing the server, AI Hosting servers with the Coolify panel preinstalled check every box on this list from the start, with root access, deploys from GitHub and Docker, and automatic SSL.
Step 1: Prepare your DNS records
In your domain's DNS panel, create two A records: one for the Coolify panel and one for the application:
coolify.ornek.com A SUNUCU_IP_ADRESI
app.ornek.com A SUNUCU_IP_ADRESI
(Here, ornek.com stands for your domain and SUNUCU_IP_ADRESI for your server's IP address.) If you plan to use pull request previews, also add a wildcard A record for *.app.ornek.com. DNS changes can take time to propagate; confirm the record resolves before moving on to the SSL step:
nslookup app.ornek.com
Step 2: Set the Coolify panel's domain
GitHub notifies Coolify of push events through a webhook. For that notification to arrive, the panel needs a public HTTPS address. In Coolify, go to Settings, enter https://coolify.ornek.com in the instance domain field and save. Coolify issues an SSL certificate for this address automatically too. From now on, use the panel at this address instead of IP:8000.
Important: If you create the GitHub App before this step, the webhook URL is registered with the IP address and automatic deploys may not work. Follow the order.
Step 3: Create a GitHub App and install it on your repositories
A GitHub App is a per-repository integration that lets Coolify read your private repositories and receive push events. It's more secure than a personal access token because it can only access the repositories you select.
- In Coolify, go to Sources and add a new GitHub App.
- Give the app a clear name. If your repositories live in a GitHub organization, enter the organization name; leave it blank for a personal account.
- When you click Register, you're redirected to GitHub. Coolify prefills the required permissions and the webhook URL; confirm creating the app on GitHub.
- Then Install the app and select the repositories it can access. Selecting only the repositories you'll deploy is the safest approach.
- Back in Coolify, check that the source shows as connected.
Step 4: Add the repository as an application
- Create a new project under Projects; it comes with a
productionenvironment by default. - Add a new resource inside the environment and choose Private Repository (with GitHub App).
- Select the GitHub App you just created, then the repository and the branch (for example
main). - Choose a Build pack:
- Nixpacks: Automatically detects and builds Node.js, PHP, Python, Go and similar projects. A good starting point for most projects.
- Dockerfile: The most predictable option if your repository has its own Dockerfile.
- Docker Compose: For projects made up of multiple services.
- Static: For sites that serve prebuilt HTML/JS output.
- In the Ports Exposes field, enter the port your app listens on inside the container.
3000is typical for Next.js and most Node.js apps, and8000for many Python apps.
If your app only listens on 127.0.0.1, the reverse proxy can't reach it and you'll get a 502 error. Start the server so it listens on 0.0.0.0. You'll find detailed tips for Next.js projects in our article on deploying a Next.js app on your own server.
Step 5: Define environment variables
On the app's Environment Variables tab, you can add variables one at a time or switch to the developer view and paste them in bulk in .env format:
NODE_ENV=production
DATABASE_URL=postgresql://kullanici:sifre@veritabani-adi:5432/uygulama
NEXT_PUBLIC_SITE_URL=https://app.ornek.com
There are two distinctions to keep in mind:
- Build time vs. runtime: Values baked into the code at build time, such as
NEXT_PUBLIC_variables in Next.js, must also be marked as available during the build. When you change them, you need to redeploy. - Secrets stay out of the repository: Don't push API keys and passwords to the repository in a
.envfile; define them only in Coolify.
If you added the database to the same project in Coolify, use the internal connection URL shown on the database page; containers reach each other by that name on the same Docker network.
Step 6: Domain and automatic SSL
In the Domains field on the app's General tab, enter the address including the protocol:
https://app.ornek.com
Starting the address with https:// tells Coolify to obtain and renew a Let's Encrypt certificate automatically through the reverse proxy. You can add multiple domains separated by commas. If you want a redirect between www and the bare domain, set the relevant option on this tab.
If the certificate can't be issued, the most common causes are: the DNS record doesn't point to the server yet, port 80 is closed (Let's Encrypt needs it for HTTP validation), or the domain sits behind a CDN proxy with a different SSL mode.
Step 7: First deploy and automatic deploys
- Click Deploy and watch the build logs. The first build takes longer than later ones because it downloads dependencies.
- When the build finishes, open
https://app.ornek.comand confirm the certificate is valid. - In the Advanced section of the app settings, check that Auto Deploy is turned on. For repositories connected through a GitHub App, every push to the selected branch triggers a new deploy while this option is on.
- To test, make a small change and push it:
git commit -am "deploy testi"
git push origin main
Within a few seconds you should see a new entry on the Deployments tab in Coolify. If you don't, check the webhook delivery history (Recent Deliveries) in the app's settings on GitHub; the error code tells you whether the problem is the webhook URL or the server.
Optional: Pull request previews
Coolify can create a separate preview environment for every pull request that's opened. Turn the feature on in the app's Preview Deployments settings and define the preview URL template based on your wildcard domain. When the PR is closed, the preview environment is removed too. Each preview runs as a separate container, so plan your server memory accordingly.
Alternative: Controlled deploys with GitHub Actions
If you want deploys to start only after tests pass, turn off Auto Deploy and call Coolify's deploy webhook from GitHub Actions. Get the webhook URL from the app's Webhooks tab and the API key from Coolify's Keys & Tokens section, then save them in your GitHub repository's secrets:
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Testler
run: npm ci && npm test
- name: Coolify deploy tetikle
run: |
curl --fail -H "Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}" "${{ secrets.COOLIFY_WEBHOOK }}"
Rolling back a bad release
The built-in risk of automatic deploys is that a bad commit also goes live automatically. Coolify keeps the images of previous builds on the server for a while. In the app's Rollback section, you can pick a previous version you know works and roll back in one click; since no rebuild is needed, the rollback is fast. Then fix the bug in Git and push a new commit. Database migrations aren't reverted by a rollback, so take care to write backward-compatible migrations for updates that change the schema.
Defining a health check for the app also helps rollbacks work reliably. For example, if an endpoint like /health doesn't return 200, Coolify won't consider the new container ready and keeps traffic on the old version.
Common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| No deploy starts after a push | Auto Deploy is off, or the webhook URL is registered with the IP | Turn the setting on; set the panel domain and recreate the GitHub App |
| 502 Bad Gateway | Wrong port, or the app listens on 127.0.0.1 | Fix the Ports Exposes value and the listen address |
| The build stops partway through | Not enough memory during the build | A server with more RAM or lighter build settings |
| The SSL certificate can't be issued | DNS hasn't propagated or port 80 is closed | Verify DNS, open the port and redeploy |
| An environment variable is empty on the front end | The variable isn't available at build time | Mark it as available during the build and redeploy |
For more detailed build and container errors, see our guide on fixing failed Coolify deploys.
Next step: set up your deploy pipeline
Automatic deploys on push need enough memory during builds and fast storage. The Sunucu Atlas SA-AI-2 Coolify server, with 4 CPUs, 8 GB of RAM and 80 GB of NVMe storage, is a balanced starting point for building and running Next.js, Laravel or Node.js projects alongside a database and Redis on the same server; it comes with the Coolify panel preinstalled, automatic SSL and one-click databases. For smaller setups or ones with more projects, compare all AI Hosting plans.
Frequently asked questions
Should I use a GitHub App or a deploy key with Coolify?
A GitHub App is recommended for private repositories and automatic deploys on push; it only accesses the repositories you select and sets up the webhook automatically. A deploy key works for a single repository, but you have to set up the webhook separately for automatic deploys.
Why doesn't a deploy start when I push to Coolify?
The most common causes are that Auto Deploy is turned off, or that the IP address was registered instead of the panel's domain when the GitHub App was created. The webhook delivery history on GitHub shows the source of the error.
Does Coolify renew SSL certificates automatically?
Yes. When you enter an address starting with https in the Domains field, a Let's Encrypt certificate is issued automatically and renewed before it expires. This requires DNS to point to the server and port 80 to be open.
Can I deploy multiple branches to different environments?
Yes. You can add the same repository as separate resources, for example the main branch in a production environment and the develop branch in a staging environment, each with its own domain and environment variables.
Do I need to redeploy after changing an environment variable?
Yes. The container must be restarted with the new values. For variables baked into the code at build time, a full rebuild is required.