CI Deployment Fails for NestJS App on Railway – Connection Refused Error
studiobo
HOBBYOP

16 days ago

Hi, I’m trying to deploy my NestJS app using CI to Railway, but the deployment is failing with a connection error.

This is the command being executed in CI:

railway up --service $SERVICE_ID --environment $RAILWAY_ENV

Environment variables:

RAILWAY_ENV=develop
SERVICE_ID=2012127f-6c5a-4bc1-afe0-b3c9c2aada26
RAILWAY_TOKEN=***

Error output:

Failed to fetch: error sending request for url (https://backboard.railway-develop.com/graphql/v2)

Caused by:
    0: error sending request for url (https://backboard.railway-develop.com/graphql/v2)
    1: client error (Connect)
    2: tcp connect error
    3: Connection refused (os error 111)

Error: Process completed with exit code 1.

Has anyone encountered this issue before or knows what might be causing it? Any help would be appreciated.

$10 Bounty

4 Replies

Status changed to Open Railway 16 days ago


16 days ago

Please remove RAILWAY_ENV=develop, as that is only used internally to test the CLI against different backends. It has no use for anyone not employed at Railway.


Status changed to Awaiting User Response Railway 16 days ago


statgod6
PRO

16 days ago

do not use RAILWAY_ENV as your project environment variable name. Rename it to RAILWAY_TARGET_ENV, DEPLOY_ENV, or similar


Status changed to Awaiting Railway Response Railway 16 days ago


Status changed to Awaiting User Response Railway 16 days ago


studiobo
HOBBYOP

16 days ago

I have removed environment and tried still getting same error

      - name: 🚀 Deploy
        run: RAILWAY_TOKEN=${{ secrets.RAILWAY_TOKEN }} railway up --service ${{ vars.RAILWAY_SERVICE_ID_DEV }}

Attachments


Status changed to Awaiting Railway Response Railway 16 days ago


tnewaz84
FREE

15 days ago

The cleanest fix is Option 1 — rename the variable entirely.

Your updated deploy step should look like this:

- name: 🚀 Deploy

shell: bash

run: railway up --service ${{ vars.RAILWAY_SERVICE_ID_DEV }} --environment ${{ vars.TARGET_ENVIRONMENT }}

env:

RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}

TARGET_ENVIRONMENT=development

TARGET_ENVIRONMENT=production

depending on your workflow.

A couple of important details:

  • --environment expects the Railway environment name, not necessarily "develop".
  • Most projects use:
    • production
    • staging
    • development

If you use Option 2 (RAILWAY_ENV: ""), it works as a workaround, but it’s brittle because:

  • another step could still inherit the bad variable,
  • future Railway CLI changes could behave differently,
  • it creates hidden configuration debt.

So structurally:

  • RAILWAY_ENV → reserved/internal
  • TARGET_ENVIRONMENT → safe custom variable
  • explicit --environment flag → best practice

I hope this helps.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...