Pre-deploy command consistently fails with no logs despite command succeeding in container
rbanner1
HOBBYOP

25 days ago

STAGING-ONLY issue. Production has not been modified and remains healthy.

ENVIRONMENT

Project: talented-commitment

Project ID: f3a62cca-b1cd-47a6-a584-d4cff78aaccc

Environment: staging

Environment ID: a3798345-d7ca-4cd8-b47c-c0b5fe5f6fe0

Service: web

Service ID: 8a124d90-d640-4ce7-b0a7-6af938d437ea

Plan: Hobby

ISSUE

Our pre-deploy command consistently fails after a successful build with only:

"Pre-deploy command failed"

No stdout, stderr, exit code, or actionable error is shown.

GraphQL deploymentEvents reports:

step: PRE_DEPLOY_COMMAND

payload.error: "Pre-deploy command failed"

deploymentLogs/buildLogs contain no pre-deploy output through CLI or GraphQL.

PRIMARY COMMAND

cd /app/packages/db && node dist/scripts/migrate.js

TESTS

  1. Normal migration command

Deployment: ceef2110-5d64-4ac4-9181-996bd9b85197

Default Railway timeout.

Failed after ~7.9s.

  1. Trivial node -e diagnostic checking only DATABASE_URL hostname

Deployment: d3ce46d5-d4c0-4006-9825-68b651f62c86

preDeployTimeoutSeconds=60.

Failed after ~6.0s.

  1. Explicit shell wrapper:

/bin/sh -c "cd /app/packages/db && node dist/scripts/migrate.js"

Deployment: 5e9972c5-e14d-4d89-bd54-c445f13bc0ec

preDeployTimeoutSeconds=60.

Failed after ~10.2s.

VERIFIED

  • Exact migration command succeeds immediately through railway ssh.
  • Migration files/dependencies are present in the runtime image.
  • DATABASE_URL is available and DB is reachable from the running container.
  • 60s timeout did not change the failure.
  • Explicit /bin/sh -c did not help.
  • Trivial diagnostic also failed in PRE_DEPLOY_COMMAND.
  • Application builds succeed.
  • Existing staging deployment remains healthy; /api/health/ready returns 200.
  • Migration ledger remained 16/16 through all tests.
  • 0015 remains applied exactly once.
  • No migrations were pending and no partial DB changes occurred.
  • Production was never modified.
  • Staging is restored to the intended fail-closed migration command.

EXPECTED

Build succeeds -> pre-deploy migration command executes -> no pending migrations -> command exits successfully -> deployment continues.

OBSERVED

Build succeeds -> PRE_DEPLOY_COMMAND -> fails after ~6-10s with only "Pre-deploy command failed." New deployment never becomes active.

QUESTIONS

Has anyone seen this behavior with Railway pre-deploy commands, particularly Dockerfile deployments or Hobby plans?

We're trying to identify anything we've missed before concluding this may be Railway-side.

  1. Is there anything incorrect about our pre-deploy command?

  2. Are there differences between railway ssh and the pre-deploy environment that could explain why the command works via SSH but fails here?

  3. Does DATABASE_URL/private-network access require anything additional during pre-deploy?

  4. Are pre-deploy commands fully supported on Hobby?

  5. Is there a way to retrieve stdout/stderr or the real process exit code when Railway only reports "Pre-deploy command failed"?

  6. Is there another safe diagnostic that would distinguish a configuration issue from a Railway execution-environment issue?

I've stopped further staging experiments pending guidance. If I'm missing a configuration requirement, we'd appreciate help identifying it. If this looks Railway-side, guidance from Railway staff on the next step would be appreciated.

Awaiting Conductor Response$10 Bounty

3 Replies

Railway
BOT

25 days ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway • 25 days ago


rbanner1
HOBBYOP

25 days ago

Resolved — thanks for the help.

Root cause was command execution semantics.

Our original pre-deploy command was:

cd /app/packages/db && node dist/scripts/migrate.js

That requires shell interpretation (cd is a shell builtin and && is shell syntax). Railway's pre-deploy execution did not implicitly invoke a shell for this command.

We changed it to:

/bin/sh -c "cd /app/packages/db && node dist/scripts/migrate.js"

and tested it on a genuinely new deployment.

Result:

  • PRE_DEPLOY_COMMAND succeeded
  • migration script completed successfully
  • application deployed successfully
  • health check returned 200
  • deployment verification passed
  • migration ledger remained correct at 16/16
  • no migration was reapplied
  • production remained untouched

One thing that complicated debugging: changing preDeployCommand and then using railway redeploy on the existing commit repeatedly produced deployments whose baked serviceManifest still contained the previous command. We only caught this by inspecting each deployment's own manifest. A genuinely new commit correctly picked up the changed command.

Thanks — issue resolved.


lordv22
HOBBYTop 10% Contributor

24 days ago

Você apenas com um aplicativo só, não tem fórmula mágica, até porque o problema simples, e você não tá vendo basta pega baixar um aplicativo da play store e resolver o problema


lordv22
HOBBYTop 10% Contributor

24 days ago

Caso saber o real problema, eu não posso ter acesso aos seus projetos mas pelo que você descreveu já sei qual é o problema, caso tenha interesse em resolver seu problema basta dizer sim e seguir os passo a passo que eu vou te informar através da play store


Welcome!

Sign in to your Railway account to join the conversation.

Loading...