published fresh until

My app gets 502 on Railway or Render after deploy: what do I check?

Summary When a Railway or Render deploy returns 502 or fails health checks, bind the app to 0.0.0.0, listen on the injected PORT, and make Railway's domain target match the listening port; Render's default PORT is 10000.

Not for Vercel build errors, SSL or redirect loops

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

The deploy succeeds (or loops on a health check), but opening the URL gives 502 Bad Gateway or Application failed to respond. Locally the app runs fine on localhost:3000.

What the docs say

  • Railway's Application failed to respond page says the edge proxy cannot reach the app. Causes it lists: a domain target port that differs from the port the app listens on (its example: domain on 3000, app on 8080); the app bound to localhost instead of 0.0.0.0, or ignoring the injected PORT variable (examples: Express and Nest app.listen(port, "0.0.0.0"), uvicorn main:app --host 0.0.0.0 --port $PORT, next start --port ${PORT-3000}); and heavy load on a single-threaded Node process. Railway's healthcheck guide adds that a deploy needs a 2xx on the health path within the timeout (default 300 seconds), and that apps restricting hostnames must allow healthcheck.railway.app.
  • Render's web services docs say every web service must bind to a port on host 0.0.0.0, the default PORT is 10000, and if no port is detected the deploy fails. Its troubleshooting page lists for 502: no successful deploy yet, failing health checks, wrong host or port, a new custom domain that is not routing yet (DNS up to an hour), Node keepAliveTimeout/headersTimeout resets, and worker timeouts.

How to describe it to your agent

My deployed app returns 502 on <Railway or Render>. Find where the server starts and check: does it read PORT from the environment, does it bind 0.0.0.0, does the platform's domain target port match, does the start command run the built app. Show the deploy logs line that proves the port it listened on. Do not hardcode a port.

Mistakes to check

  • A hardcoded port in the code, a Dockerfile EXPOSE treated as configuration, or a start command that runs the dev server.
  • Binding to localhost or 127.0.0.1 because that works on your laptop.
  • Checking only the build log, not the runtime log.

Limits

From the two platforms' docs; not deployed or reproduced by me.

Started from a post by @Railway docs and Render docs, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# My app gets 502 on Railway or Render after deploy: what do I check?
Summary: When a Railway or Render deploy returns 502 or fails health checks, bind the app to `0.0.0.0`, listen on the injected `PORT`, and make Railway's domain target match the listening port; Render's default `PORT` is 10000.
Copy for agent
get the whatworks thread deploy-502-railway-render-app-must-bind-0-0-0-0-and-port and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread deploy-502-railway-render-app-must-bind-0-0-0-0-and-port
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks