2 days ago
My Spring Boot app deploys successfully (status: ACTIVE, "Deployment successful") and logs show Tomcat started on port 8080 with server.address=0.0.0.0 explicitly set. I've set the target port to 8080 in Public Networking settings. However, visiting the public URL still shows "Application failed to respond" (502).
I've tried:
- server.port=${PORT:8080} and server.address=0.0.0.0 in application.properties
- Removed healthcheck from railway.json
- Set target port to 8080 manually in settings
- Redeployed multiple times via railway up --detach
- Removed PORT env variable (letting Railway inject it)
URL: bow-backend-production.up.railway.app
Project ID: 2e1e2611-59df-4636-824b-636e3b8b7010
GitHub repo: https://github.com/harijantoliu-max/bow-backend
What else could cause this?
7 Replies
2 days ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • 2 days ago
2 days ago
Try setting the PORT variable to 8080 explicitly, and make your app listen on it instead of hardcoding it.
2 days ago
If that doesn't work, try changing the port to 3000 both in your app and in the target port.
2 days ago
Update: I confirmed the app is working perfectly from inside the container. Using Railway's Console feature, I ran:
wget -qO- http://localhost:8080/api/branches
This returned valid JSON data successfully:
[{"id":1,"name":"BOW Kelapa Gading",...},{"id":2,"name":"BOW Sunter",...}]
So the app IS listening on 0.0.0.0:8080 and responding correctly internally. The issue must be with Railway's edge proxy/routing not reaching the container, since the public domain still returns "Application failed to respond" (502).
Could someone from the team check the routing for this deployment specifically?
2 days ago
Since Railway reports the deployment as successful and Tomcat starts correctly, the most likely causes of the 502 are that the application is not actually binding to Railway's injected $PORT, a startup dependency (database, Redis, external API, etc.) is hanging or failing after Tomcat starts, Spring Security or a filter is blocking requests, or there is no valid endpoint at /. Set server.port=${PORT} (without the :8080 fallback) and server.address=0.0.0.0, add a simple test controller such as @GetMapping("/") returning "OK", temporarily disable security and database initialization, redeploy, and check whether the startup log shows the exact port Railway injected rather than a fixed 8080. If the root endpoint still returns a 502 despite a successful deployment and no runtime errors in the logs, the issue is likely in the container configuration (Dockerfile, exposed port, or process startup command) rather than the Spring Boot application itself.
