> Source: https://meetrix.io/blogs/coolify-bad-gateway/
> Markdown copy of that page. Cite the URL above, not this file.

Development

# Coolify Bad Gateway (502): How to Fix It, Plus Other Common Errors

[By Binuka Ranatunga](https://meetrix.io/blogs/authors/binuka-ranatunga/) • September 29, 2026 • 8 min read

Revised by

-   ![Portrait of Hiruna Kumara, Senior DevOps Engineer at Meetrix](https://meetrix.io/blog-images/assets/authors/hiruna-kumara.webp)[Hiruna Kumara](https://meetrix.io/blogs/authors/hiruna-kumara/)Senior DevOps Engineer, Meetrix

This article was reviewed and refreshed for accuracy. Last reviewed September 2026.

The build succeeded. The container is running. And the domain still shows 502 Bad Gateway.

When Coolify does this, the app is rarely the problem. Traefik, the reverse proxy Coolify puts in front of every app, got the request and couldn't reach the container behind it. This guide covers the fix for that, the difference between restarting the proxy and restarting Coolify, what "Coolify down" after a reboot usually means, rollbacks, and the other errors people hit next. If you are setting up a fresh server instead, our [Coolify hosting AMI on AWS](https://meetrix.io/blogs/coolify-ami-self-host/) ships with the proxy and Docker already configured.

Quick answer

Check the Port Exposes field on the application first. It has to match the port your app listens on inside the container, not a host port. Then make sure the app binds to 0.0.0.0, not localhost. And delete any `ports:` mapping from your compose file, because it fights with Coolify's proxy.

## Why the Coolify Bad Gateway Error Happens

A 502 from Coolify means [Traefik](https://doc.traefik.io/traefik/) matched your domain to a container and then failed to open a connection to it. The app never saw the request. That narrows it down to three causes:

-   The container crashed, or it hasn't finished starting.
-   Traefik is sending traffic to a port the app isn't listening on.
-   The app only accepts connections on localhost, so nothing outside its own container can reach it.

## Checking Port Exposes and binding

This fixes most 502s, and it's two settings, not one.

**Port Exposes**, on the application's configuration page, has to equal the port your app binds to inside the container. If the app listens on 3000 and Port Exposes says 8080, Traefik routes every request to a port where nothing is listening. It looks like an infrastructure failure. It's a typo.

The second setting lives in your code: the app must listen on `0.0.0.0`. Plenty of dev servers (Vite, Next.js in some modes, Flask) default to `127.0.0.1`, which works on your laptop and fails behind any proxy.

| Symptom | Likely cause |
| --- | --- |
| 502 on domain, works on server IP:port directly | Port Exposes mismatch, or a host port mapping bypassing the proxy |
| 502 immediately after deploy, clears after a minute | App still starting, Traefik hit it before the process was ready |
| 502 that never clears | App bound to 127.0.0.1 instead of 0.0.0.0, or the app actually crashed |

If your compose file has its own `ports:` mapping to the host, remove it. Coolify's proxy owns routing, and a manual host mapping gets in its way rather than acting as a fallback.

## How to Restart Coolify and Its Proxy

"Restart Coolify" means two different things. If one app is misbehaving, restart the proxy, either from the dashboard or directly:

```bash
docker restart coolify-proxy
docker logs coolify-proxy --tail 100
```

If the Coolify dashboard itself won't load, restart Docker instead:

```bash
sudo systemctl restart docker
docker ps -a
```

Coolify's containers use a [restart-always policy](https://docs.docker.com/engine/containers/start-containers-automatically/), so once Docker is healthy they come back on their own.

## Coolify down after a reboot

When Coolify is down after a server restart, Coolify is rarely the culprit. Docker didn't start on boot, or it started late. Check that first:

```bash
systemctl is-enabled docker
docker ps
```

If Docker isn't enabled on boot, run `sudo systemctl enable docker` and reboot again. If Docker is running but Coolify's containers aren't in the list, re-run the [official install script](https://coolify.io/docs/get-started/installation). It detects the existing install and brings it back up (updating it on the way) instead of starting from scratch.

## Rolling back a bad deploy

Coolify can roll back from the application's Deployments tab. The catch: it only rolls back to an image that is still on the server. If Coolify pruned the old image to free disk space, or your build pulls fresh from a registry every time, there is nothing local to go back to.

Plan for this before you need it

If rollback is part of your incident plan, check your image retention settings now. Finding out mid-outage that the previous image is gone is the worst time to learn it.

## Other common Coolify errors

-   **Build succeeds, deploy hangs forever:** usually a health check pointed at a path or port the app doesn't serve.
-   **Works right after deploy, breaks a few minutes later:** check container memory limits. An app getting OOM-killed looks like random instability, not a crash.
-   **SSL certificate errors on a custom domain:** confirm DNS points at the server first. Let's Encrypt can't issue a certificate for a domain that resolves somewhere else.

### Coolify "server is not reachable"

Coolify manages every server, including the one it runs on, over SSH. This error means that SSH connection failed. Check that port 22 is open from the Coolify host, that the server's firewall (or a fail2ban ban after too many attempts) isn't blocking it, and that the key Coolify holds is still in the server's `authorized_keys`.

### "Cannot connect to real-time service"

The dashboard's live updates come from a separate real-time container that listens on ports 6001 and 6002. The warning means your browser can't reach it, almost always because those ports are closed in the firewall or the AWS security group. Deploys still work; you just lose live logs and status updates until you open them.

### Resetting a forgotten Coolify password

There is no email reset on a fresh self-hosted install. Reset the root user from the server instead:

```bash
docker exec -ti coolify sh -c "php artisan root:reset-password"
```

If you haven't deployed Coolify yet, our [Coolify developer guide](https://meetrix.io/blogs/coolify-dev-guide/) and [single-click AWS setup](https://meetrix.io/blogs/setup-coolify-aws-single-click/) get it running with these settings right from the start. Still deciding whether to self-host at all? [Coolify vs Vercel and Netlify](https://meetrix.io/blogs/coolify-vs-vercel-netlify/) covers that trade-off.

## Frequently Asked Questions

What causes a Coolify bad gateway error?

Traefik, Coolify's proxy, can't reach your app's container. It is almost always one of three things: the app crashed, Port Exposes has the wrong port, or the app listens on 127.0.0.1 instead of 0.0.0.0.

How do I fix a coolify 502 bad gateway specifically?

Set Port Exposes to the port your app listens on inside the container, make the app bind to 0.0.0.0, and delete any host `ports:` mapping from your compose file. Then redeploy.

How do I restart Coolify?

For one broken app, restart the proxy with `docker restart coolify-proxy`. If the dashboard itself is dead, restart Docker with `sudo systemctl restart docker`; Coolify's containers come back on their own.

Why is Coolify down after a server reboot?

Usually Docker didn't start on boot. Check `systemctl is-enabled docker`, then `docker ps`. If Docker runs but Coolify's containers are missing, re-run the official install script; it repairs an existing install.

How do I reset a forgotten Coolify password?

On the server, run `docker exec -ti coolify sh -c "php artisan root:reset-password"` and follow the prompt. It resets the root user's password without touching your apps.

Does Coolify support rolling back a deployment?

Yes, from the application's Deployments tab, but only to images still stored on the server. If Coolify already pruned the old image, there is nothing to roll back to.

## Skip the Self-Managed Headaches

Launch a pre-configured Coolify server on AWS with the proxy and networking already set up correctly from the first deploy.

[Get Coolify on AWS Marketplace](https://aws.amazon.com/marketplace/pp/prodview-xtwosdmkukfjc)

Meetrix Store

Coolify

Deploy from Git, a Heroku alternative

[Deploy it](https://meetrix.io/store/coolify/)

Meetrix Store New

Deploy what this guide covers, pre-configured.

-    [Coolify Deploy from Git, a Heroku alternative](https://meetrix.io/store/coolify/)
-    [Plane Issues, cycles and roadmaps, a Jira alternative](https://meetrix.io/store/plane/)
-    [Supabase Postgres, Auth, Storage and Realtime, self-hosted](https://meetrix.io/store/supabase/)
-    [Jitsi Meet Self-hosted video calls for 50 to 500 users](https://meetrix.io/store/jitsi-meet/)
-    [RustDesk Remote desktop AMI, a TeamViewer alternative](https://meetrix.io/store/rustdesk/)
-    [Coturn TURN/STUN for WebRTC, no per-minute relay fees](https://meetrix.io/store/coturn/)

[Browse all products](https://meetrix.io/store/)
