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 ships with the proxy and Docker already configured.
Quick answer
ports: mapping from your compose file, because it fights with Coolify's proxy.
Jump to a section
Why the Coolify Bad Gateway Error Happens
A 502 from Coolify means 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:
docker restart coolify-proxy
docker logs coolify-proxy --tail 100 If the Coolify dashboard itself won't load, restart Docker instead:
sudo systemctl restart docker
docker ps -a Coolify's containers use a restart-always policy, 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:
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. 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
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:
docker exec -ti coolify sh -c "php artisan root:reset-password" If you haven't deployed Coolify yet, our Coolify developer guide and single-click AWS setup get it running with these settings right from the start. Still deciding whether to self-host at all? Coolify vs Vercel and 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