I am deploying a NestJS backend connected to a Railway Postgres database
bernardsdev
HOBBYOP

18 days ago

The deployment has been failing inconsistently with two issues:

1. Build infrastructure timeout — The BuildKit execution phase hangs for ~40 minutes with zero log output before timing out. Railway's own diagnosis confirmed this is a builder infrastructure issue, not a code problem, since the exact same commit built successfully 2 minutes prior.

2. Cannot find module '/app/dist/src/main' — When the build does complete, the compiled dist/ folder is not available in the deploy container, causing an immediate crash on startup. The build command (npm install --include=dev && npm run build) runs nest build successfully during the build phase, but dist/src/main.js is missing at runtime.

3. False "successful" state — When redeploying after a crash, Railway shows "Deployment successful", the ew.backend service shows as Online, and the deployment status shows Completed — but the service crashes immediately after. The Online status is misleading as the app is not actually running.

Build command: npm install --include=dev && npm run build Start command: node dist/src/main Builder: RAILPACK / BuildEnvironment V3 Runtime: V2 I have tried: - Setting explicit build and start commands in Settings - Adding a railway.json with RAILPACK builder config - Adding nixpacks.toml to control install/build/start phases - All result in the same outcome

Please advise on why build artifacts are not persisting to the deploy container, and why builds are hanging intermittently.

$10 Bounty

1 Replies

Status changed to Open Railway 18 days ago


i-smuglov
FREETop 5% Contributor

15 days ago

Try to deploy in a different region for now


Welcome!

Sign in to your Railway account to join the conversation.

Loading...