medusa: Healthcheck Fails after Default Deployment to Railway from Medusa Docs

Bug report

Describe the bug

After running a default deployment to Railway using the provided steps from the Medusa documentation, the healthcheck consistently failed. The service repeatedly returned “service unavailable” across all attempts.

System information

Medusa version (including plugins): backend template Node.js version: not sure Database: Postgres and redis Operating system: n/a Browser (if relevant):

Steps to reproduce the behavior

1.	Follow the default deployment guide provided by Medusa for Railway.
2.	Observe the healthcheck status after deployment.

Expected behavior

The healthcheck should succeed and the service should be available.

Screenshots

If applicable, add screenshots to help explain your problem

Code snippets

Pushing [==================================================>]  670.8MB 76f1e49ca557
Pushed  76f1e49ca557
2919c052-6a54-4066-93cb-f2dc99018ef8: digest: sha256:1242fafbc7ccd3baa728cd52af4586839547c039e1c46fb9b469660e1eae9678 size: 2842
Publish time: 34.01 seconds

Starting Healthcheck

Path: /health
Retry window: 5m0s

Attempt #1 failed with service unavailable. Continuing to retry...
... Attempt #14 failed with service unavailable. Continuing to retry for 28s

1/1 replicas never became healthy!
Healthcheck failed!

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 6
  • Comments: 23 (4 by maintainers)

Most upvoted comments

Incase this helps anyone else the problem I was getting an error saying health checked failed deploying to digital ocean apps.

In the medusa docs it says more time is needed between the build and health check so I set the deley health check to 300s and it seems to work. so have a look on your hosting and see if this option is there.

I assume medusa takes a little longer than standard node apps to completely spin up .

hope this helps someone

@samhenderson511 can confirm that I have the admin working via Vercel and that it’s connected to the backend so I’m able to login, create a product etc.

A few changes I made to deploying to Railway:

  • Set the @medusajs/admin plugin’s autoRebuild option to false
  • Changed the build:admin script in my package.json to medusa-admin build --deployment
  • Changed the Build Command in Railway back to yarn run build
  • The Start Command in Railway is set to the recommended medusa migrations run && medusa start

So my medusa-config.js plugins looks like so:

const plugins = [
  `medusa-fulfillment-manual`,
  `medusa-payment-manual`,
  {
    resolve: `@medusajs/file-local`,
    options: {
      upload_dir: "uploads",
    },
  },
  {
    resolve: "@medusajs/admin",
    /** @type {import('@medusajs/admin').PluginOptions} */
    options: {
      autoRebuild: false,
    },
  }
];

My package.json scripts:

{
    "clean": "./node_modules/.bin/rimraf dist",
    "build": "npm run build:server && npm run build:admin",
    "build:server": "tsc -p tsconfig.json",
    "build:admin": "medusa-admin build --deployment",
    "watch": "cross-env tsc --watch",
    "test": "cross-env jest",
    "seed": "cross-env medusa seed -f ./data/seed.json",
    "start": "npm run build && medusa start",
    "start:custom": "npm run build && node --preserve-symlinks --trace-warnings index.js",
    "dev": "cross-env npm run build:server && medusa develop"
  }

I also have environment variables pointing towards the Railway Postgres and Redis instances as mentioned by @shahednasser above.

COOKIE_SECRET=your_secret
DATABASE_TYPE=postgres
JWT_SECRET=your_secret
PORT=9000
DATABASE_URL=${{Postgres.DATABASE_URL}}
REDIS_URL=${{Redis.REDIS_URL}}

I then followed the instructions to deploy the admin to Vercel here: https://docs.medusajs.com/deployments/admin/deploying-on-vercel