Skip to content

railway add -d <database> fails with "Unauthorized" despite valid authentication #830

@cristiantrapero

Description

@cristiantrapero

Description

The railway add -d <database> command fails with an "Unauthorized" error even when the user is properly authenticated. Other commands that require authentication (railway init, railway up, railway variable set, railway domain, etc.) work correctly in the same session.

Environment

  • Railway CLI version: 4.36.0
  • OS: Linux 6.17.0-19-generic x86_64 (Ubuntu)
  • Shell: bash
  • Auth method: railway login

Steps to reproduce

# 1. Verify authentication works
railway whoami
# Output: Logged in as <user> (<email>) 👋

# 2. Create a new project (works fine)
railway init --name "test-project" --workspace "<workspace-id>"
# Output: Created project test-project

# 3. Try to add a database
railway add -d mysql
# Output:
# > What do you need? Database
# Unauthorized. Please run `railway login` again.
Image

The same error occurs with:

  • railway add -d redis
  • railway add -d postgres
  • railway add -d mongo
  • railway deploy -t redis

Expected behavior

The database service should be created in the linked project without requiring re-authentication.

Actual behavior

The command prompts > What do you need? Database and then immediately fails with:

Unauthorized. Please run `railway login` again.

Running railway login again does not fix the issue. The token is valid for all other operations.

Workaround

Creating the database manually from the Railway dashboard works. All other CLI commands (railway up, railway variable set, railway domain, railway environment new, etc.) function correctly with the same session.

Additional context

  • The railway add -s <name> command (creating an empty service) does work in the same session.
  • Only database/template provisioning operations seem affected.
  • Tested across multiple workspaces with the same result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions