16 days ago
Hey team.I'm having a frustrating issue with a Node.js/Express backend that runs perfectly locally but keeps crash-looping on Railway.
The problem:
My app starts (Server running on port 8080), but Railway stops the container ~3 seconds later and restarts it in a loop. No error is printed after startup — the process just dies silently.
What I've ruled out:
- App runs fine locally with
NODE_ENV=production node src/app.js— no crashes - DATABASE_URL` is set and Prisma connects successfully (migrations run fine in logs)
- No hardcoded PORT — I let Railway inject it
- trust proxy 1` is set (was getting ERR_ERL_UNEXPECTED_X_FORWARDED_FOR from express-rate-limit, now fixed)
- No placeholder env vars
- uncaughtException
andunhandledRejection` handlers are in place but nothing is logged before the stop
Relevant log pattern:
Starting Container
Prisma: No pending migrations to apply
Stopping Container ← happens ~3s after start, no error
Starting Container
Server running on port 8080
Environment: production
(dies again)Stack: Node 22, Express, Prisma 5.22, express-rate-limit, Railway Postgres (internal URL)
Is Railway sending a health check signal that my app isn't responding to in time? Could there be a startup timeout I'm hitting? Any way to see what signal is killing the container?
Thanks
7 Replies
16 days ago
You have a pre-deploy command set, so that runs, the pre-deploy container stops, and then the runtime container starts.
I'm sorry, Is that the issue?
What am I to do. I've been debugging for hours.
16 days ago
That is not an issue. If you are experiencing a real issue, then you have gone down a rabbit hole here.
Please explain the issue, not what you think is causing the issue.
My frontend at https://patrioticng.org is getting a CORS error when hitting https://patriotic-backend-production.up.railway.app/diaspora and https://patriotic-backend-production.up.railway.app/contact. The preflight OPTIONS request returns a 502 with no Access-Control-Allow-Origin header. CORS is configured correctly in railway. Why would a 502 be returned instead of my app handling the preflight?
15 days ago
(no markdown available for this content)
15 days ago
(no markdown available for this content)
Status changed to Solved brody • 14 days ago