502 "Application failed to respond" — app starts successfully but proxy can't reach it
mihir3502
HOBBYOP
a month ago
Platform: Railway (Docker builder) Runtime: Node.js 20 / Express on Debian Bullseye Slim Database: SQLite via Prisma
What's happening: My backend deploys successfully and the logs confirm the app is running:
SAR backend running on port 3001
But every request through the Railway-provided domain returns a 502 "Application failed to respond" error.
My setup:
EXPOSE 3001in DockerfilePORT=3001set in Railway VariablestargetPort = 3001inrailway.toml- App binds to
0.0.0.0explicitly:app.listen(3001, '0.0.0.0', ...) startCommand = "npx prisma db push && node dist/index.js"inrailway.toml
What I've tried:
- Set
PORT=3001as an explicit Railway Variable - Added
targetPort = 3001torailway.toml [deploy] - Changed
app.listen()to explicitly bind to0.0.0.0 - Tried baking startup into a
start.shscript usingexec node(PID 1) instead ofstartCommand - Confirmed
prisma db pushsucceeds in deploy logs before the app starts
Question: Is there something else Railway's edge proxy requires beyond targetPort, EXPOSE, and 0.0.0.0 binding? Could startCommand running as a shell chain (&&) prevent Railway from detecting the correct PID or port? Is there a way to view what port Railway's proxy is actually trying to connect to?
0 Replies