23 days ago
Hi Railway Team,
I'm experiencing a persistent 502 Bad Gateway error on my Ktor (Kotlin)
backend service. The app starts and runs successfully but Railway's proxy
cannot reach it.
## Service Details
- Framework: Ktor (Kotlin) with Netty engine
- Build: Multi-stage Dockerfile (gradle:9.1.0-jdk21 → eclipse-temurin:21-jre-alpine)
- Deployment status: Green / Active
- PORT variable: 8080 (set in Variables tab)
- Target port in Networking settings: 8080
## Deploy Logs (successful startup)
Starting Container
>>> PORT env value: 8080
>>> Starting server on port: 8080
Using system environment variables
Database connected successfully
Database tables verified
Application started in 4.579 seconds.
Responding at http://0.0.0.0:8080
## The Problem
Despite the app clearly binding to 0.0.0.0:8080 and the deployment
showing green/active status, every HTTP request to the Railway public
domain returns 502 Bad Gateway.
## What I Have Tried
- Set PORT=8080 in Variables tab
- Set target port to 8080 in Networking settings
- Deleted and regenerated public domain multiple times
- Deleted and recreated the entire project from scratch
- Removed railway.toml completely
- Cleared start command and let Dockerfile ENTRYPOINT handle it
- Changed ENTRYPOINT to exec form: ["java", "-jar", "/app/app.jar"]
- Updated application.yaml to use port: ${PORT}
Nothing has resolved the 502. The app boots perfectly every time but
Railway's edge proxy cannot route traffic to it.
## Dockerfile ENTRYPOINT
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
## Application binding code (Application.kt)
val port = System.getenv("PORT")?.toIntOrNull() ?: 8080
embeddedServer(Netty, host = "0.0.0.0", port = port) {
module()
}.start(wait = true)
Please check your proxy/edge logs for my service to identify
why traffic is not being routed to the running container.
Thank you.
1 Replies
Status changed to Open Railway • 23 days ago
23 days ago
Can you make sure your host in application.yaml is set to 0.0.0.0 ? If you don't set it, it might default to localhost or 127.0.0.1. Check if your healthcheck is passing as well.