Skip to content

Fix a 502 Bad Gateway error

A 502 Bad Gateway means your web server (nginx) tried to pass the request to your app — and the app wasn’t there, crashed, or returned garbage. The site itself is reachable; the app behind it isn’t responding.

The usual causes (most common first)

1. The app isn’t listening on $PORT. This is #1 for deployed apps. OrbixPanel sets a PORT env var and proxies to it — if your code hard-codes 3000/8080, nginx connects to the wrong place. Read the port from the environment. → How deploys work

2. The app crashed on startup. Check the deploy/app log (in the panel or the web terminal). A stack trace at boot — a missing env var, a failed DB connection, a syntax error — means the process died and nginx has nothing to talk to.

3. The app is still starting. Heavy apps take a moment. If a 502 appears right after a redeploy and clears in a few seconds, that was just the restart window.

4. For PHP: php-fpm is down or the socket is wrong. A PHP 502 usually means php-fpm isn’t running for that site’s PHP version. Check services, and confirm the site’s PHP version.

5. Out of memory. If the server is out of RAM, the app (or php-fpm) gets killed. → Disk & memory

Fast triage

  1. Open the app’s log — does it show a crash? Fix the error, redeploy.
  2. Confirm the app reads process.env.PORT (Node) / binds 0.0.0.0:$PORT.
  3. free -m — is memory exhausted?
  4. For PHP, verify php-fpm is running.

See also the site-down checklist.


Running OrbixPanel? App logs and restarts are one click in the panel. OrbixPanel.com → — the free, self-hosted, AI-powered hosting control panel.