Deployment Issue – Caddy on Railway returning 404 for all routes
kingmaker-code
HOBBYOP

10 months ago

Hey, I’ve deployed my app on Railway server. The deployment logs show that Caddy starts correctly, but I’m getting 404 Not Found errors for all routes when I visit the live site, including / and /login.

🔧 Setup:
• Deployment target: Railway
• Web server: Caddy
• Purpose: Serving frontend (Vite/React)
• Caddy logs:
{"level":"info","ts":…,"msg":"serving initial configuration"}
{"level":"info","ts":…,"msg":"serving HTTP on [::]:80"}
{"level":"info","ts":…,"logger":"http.log.access","msg":"handled request","request":{"method":"GET","uri":"/","proto":"HTTP/1.1"},"status":404}

🧩 What I’ve tried:
• Checked that the server is up and logs show no fatal errors
• Routes like / and /login all return 404

Thanks in advance! 🙏

Solved

22 Replies

kingmaker-code
HOBBYOP

10 months ago

10fb3aa6-8aa3-401a-bf20-624a21c44ebe


kingmaker-code
HOBBYOP

10 months ago

@Brody sorry for the ping but its in some urgency mode


10 months ago

i'm sorry but we don't offer urgent support for non-platform related issues, i will come back to this thread when i have some spare time or a community member may pop in to help you before that


kingmaker-code
HOBBYOP

10 months ago

I’m deploying a simple frontend (built with Vite) on Railway using the default Railpack (no custom Dockerfile). Everything seems to build and deploy correctly, but all routes (even /) are returning 404 in the logs:


kingmaker-code
HOBBYOP

10 months ago

<:cryingman:786867299553378324>


10 months ago

can you share your caddyfile?


kingmaker-code
HOBBYOP

10 months ago

I have not explicitly defined the caddy configurations its just what logs files are showing so TL;DR I have no caddy file


kingmaker-code
HOBBYOP

10 months ago

2025-05-06T15:01:01.264519938Z [INFO] handled request bytesread=0 duration=0.000191314 logger="http.log.access.log0" request={"clientip":"49.43.161.118","headers":{"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Accept-Language":["en-US,en;q=0.5"],"Priority":["u=0, i"],"Sec-Fetch-Dest":["document"],"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-Site":["cross-site"],"Sec-Fetch-User":["?1"],"Te":["trailers"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:138.0) Gecko/20100101 Firefox/138.0"],"X-Forwarded-For":["49.43.161.118"],"X-Forwarded-Host":["king-maker.up.railway.app"],"X-Forwarded-Proto":["https"],"X-Railway-Edge":["railway/asia-southeast1-eqsg3a"],"X-Railway-Request-Id":["DlaFFj97Sp2acMU3U2VV7A1774336823"],"X-Real-Ip":["49.43.161.118"],"X-Request-Start":["1746543658495"]},"host":"king-maker.up.railway.app","method":"GET","proto":"HTTP/1.1","remoteip":"100.64.0.4","remoteport":"43344","uri":"/"} respheaders={"Server":["Caddy"]} size=0 status=404 ts=1746543658.501624 user_id=""

These are the logs I am getting


10 months ago

just like to give you a friendly reminder that we do not offer urgent or any guarantee of a response within a specific time frame on the hobby plan, the conductors are volunteers, please be respectful of their time, and thank you for your patience.


kingmaker-code
HOBBYOP

10 months ago

Hey Brody, totally understood — I really appreciate the work you and the other conductors do here. I didn’t mean to sound demanding earlier, just got a bit stuck and stressed. Thanks for the reminder, and I’ll be more mindful going forward 🙏


10 months ago

my message was in response to the gif as it can be seen as impatience


10 months ago

@Vidhayak Ji is your vite building to the default dist folder?


kingmaker-code
HOBBYOP

10 months ago

yes


10 months ago

^



kingmaker-code
HOBBYOP

10 months ago

okay just a min let me take a look


10 months ago

You can overwrite it by creating your own Caddyfile at root


kingmaker-code
HOBBYOP

10 months ago

okay let me try it


kingmaker-code
HOBBYOP

10 months ago

and update it here


kingmaker-code
HOBBYOP

10 months ago

this is caddyfile I am using now

global options

{
admin off
persistconfig off autohttps off

log {
    format json
}

servers {
    trusted_proxies static private_ranges 100.0.0.0/8
}

}

:{$PORT:80} {
log {
format json
}

respond /health 200

header {
    X-Content-Type-Options "nosniff"
    -Server
}

root * /usr/src/app/web/dist

file_server {
    hide .git
    hide .env*
}

encode {
    gzip
    zstd
}

try_files {path} {path}.html {path}/index.html /index.html

}

1369363931298009300


kingmaker-code
HOBBYOP

10 months ago

its resolve now thanks to elon musk for his grok and medim


10 months ago

!s


Status changed to Solved medim 10 months ago


Loading...