2 months ago
Hi Railway Support Team,
I'm experiencing a persistent 502 Bad Gateway error on my backend service, even though the deployment logs clearly show the server is running successfully.
Service Details:
Service: nexus-project (backend)
Environment: Production
Root Directory: /backend
Issue Description:
The server starts successfully and logs show it's listening on port 8080
Heartbeat logs confirm the process is continuously running
However, all HTTP requests return 502 Bad Gateway
The HTTP logs show:
GET / 502for all endpoints
What I've Tried:
Removed manual PORT variable and let Railway auto-assign (it assigned 8080)
Confirmed server binds to
0.0.0.0:8080Tested with minimal HTTP server to rule out application code issues
Server process remains healthy with continuous heartbeat logs
Deploy Logs (showing successful startup):
> node minimal.js
[2025-09-22T05:15:17.484Z] Starting minimal server...
[2025-09-22T05:15:17.491Z] Server listening on 0.0.0.0:8080
[2025-09-22T05:15:22.495Z] Heartbeat - server still running
[2025-09-22T05:15:27.501Z] Heartbeat - server still running
HTTP Logs (showing 502 errors):
GET / 502 168ms
GET /health 502 3ms
The server is clearly running and healthy, but Railway's proxy layer seems unable to route traffic to it. This appears to be a platform-level routing issue rather than an application problem.
Could you please investigate why the proxy cannot connect to my running service?
Request ID from one of the 502 errors: jTzKFpGtSRuQyYluacI7Nw
Thank you for your help!
9 Replies
2 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
2 months ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 3 months ago
2 months ago
Howdy hey!
I've had this happen a few times and its usually an odd problem.
Can you confirm, in your minimal.js service are you binding to a .env port or a constant value.
If a value defined in .env, I'd suggest temporarily hard coding 8080 for debugging purposes. In both Railway variables and service.
2 months ago
In your server code, replace hardcoded ports with process.env.PORT:
const express = require("express");
const app = express();
const PORT = process.env.PORT || 8080; // use Railway's injected port
app.listen(PORT, "0.0.0.0", () => {
console.log(`Server listening on 0.0.0.0:${PORT}`);2 months ago
@error Is this not because of the outage going on currently?
rishimohan
@error Is this not because of the outage going on currently?
2 months ago
The outage is currently resolved as can be seen: https://status.railway.com/cmfv2ciuy00krz1jvwfghr4gz
This thread is dated 6-7 hours before this outage was reported.
Unsure if its a similar issue.
2 months ago
Might be, but the outage is definitely not resolved. Without any change, I'm still getting errors while starting my app
2 months ago
If you're having any major issues with deployments feel free to create a new thread! Would be happy to provide any support in a new thread.
According to the status page this has been resolved. I am personally not experiencing any issues either.
Attachments
2 months ago
Fixed now after filling the right port in the network setting.
Status changed to Solved noahd • 3 months ago