5 months ago
Hello, since yesterday I have a problem with my projects on railway because it reads them as caddy (only static files) and it doesn't want to read the node backend, please help me.
4 Replies
5 months ago
Hey! Railway's auto-detection switched your Node backend to Caddy, which means it's not finding your Node files properly. Make sure you have a package.json in your repo root - Railway uses that to detect Node projects. If it's there but still detecting as Caddy, you can force Node by adding a nixpacks.toml file with [phases.setup] providers = ["node"] or set a custom start command in your Railway service settings. Did something change in your repo structure yesterday? Check if your package.json got moved or deleted.
5 months ago
Option 1: Adjust Root Directory (Recommended)
If your package.json is in a subfolder (e.g., /backend), tell Railway where it is:
- In your Railway service dashboard, go to Settings.
- Find the Root Directory option.
- Enter the name of your folder (e.g.,
backend). - Redeploy.
Option 2: Force Node.js Start Command
If the file structure is correct, manually force the Node.js build process:
- Go to the Settings tab of your service.
- In the Deploy section, find the Start Command.
- Set it to your Node.js start script (e.g.,
npm start).
Make sure to
- Ensure your
package.jsonis in the directory you specified. - Make sure the
package.jsonincludes a valid"start"script (e.g.,"start": "node index.js").
This worked for me so i hope it helps!
5 months ago
Hey @zxq041
yeah this is annoying when it happens. Railway probably cant see your package.json so it defaults to caddy because it thinks youre just serving static files
Quick fix is what @dardameiz said but heres the step by step
If your package.json is in a subfolder:
- go to your service settings in railway
- scroll to root directory
- type in whatever folder has your package.json like
backendorserver - redeploy
If package.json is at the root but still broken:
You can manually override the detection by adding a nixpacks.toml file at your repo root
[phases.setup]
providers = ["node"]
or just set a custom start command in railway settings like npm start or node index.js depending on what your package.json has
@alexxdf28-hue has the right idea too with checking your start script in package.json. make sure thats actually there
Did you push any changes yesterday that couldve moved files around or deleted package.json by accident? thats usually what causes this
let us know if youre still stuck and drop your logs if nothing works
5 months ago
Hey, could you solve it? 🙂