3 months ago
Hello,
I’m experiencing intermittent 502 Bad Gateway errors on my backend service.
The issue occurs suddenly while the service is running normally, and the logs show this:
“error”: “connection closed unexpectedly”
## What I have confirmed so far
- Build succeeds without issues.
- Healthcheck /healthz) passes.
- Container starts normally.
- No crash logs inside the application.
- The 502 happens before the request reaches the app — nothing appears in app logs.
## Suspected issue
This looks like a gateway-to-container connection problem, possibly related to:
- Incorrect port detection by the platform
- Gateway timeout/reset
- Reverse proxy losing connection to the running container
## What I need help with
Could you please verify:
1. Which port the platform expects the container to listen on?
(Some systems override PORT env to 8080 automatically.)
2. If any gateway-level timeout or connection reset is occurring?
3. Whether the reverse proxy is successfully forwarding traffic to the container?
4. What the internal meaning of:
is on your infrastructure.
## Additional context
My backend listens on:
And logs the actual port at runtime.
Thanks in advance — any insight into why the gateway occasionally returns a 502 will be greatly appreciated.
4 Replies
3 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!
3 months ago
the error continues
3 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 ray-chen • 3 months ago
3 months ago
i'm having a similar problem: https://station.railway.com/questions/railway-docker-app-returns-502-bad-gatew-e0b1f3a7
3 months ago
That Railway resource is no longer in existance @ercanatbas. Can you please let me know which deploy/service/etc?