Skip to content

CLI authentication fails with valid API token on Linux #699

@anderson-ufrj

Description

@anderson-ufrj

Description

The Railway CLI fails to authenticate using a valid API token created from the Account Settings page. Both railway login and token-based authentication methods are not working.

Environment

  • OS: Linux 6.17.0-6-generic (Ubuntu-based)
  • Railway CLI versions tested:
    • 4.11.0 (binary from /usr/local/bin)
    • 4.11.1 (npm global install)
  • Node.js: v20.19.4
  • npm: 9.2.0

Steps to Reproduce

  1. Created a new API token from https://railway.app/account/tokens
  2. Attempted authentication using multiple methods:

Method 1: Browser login

$ railway login
> Open the browser? Yes
Unauthorized. Please login with `railway login`

Method 2: Browserless login

$ railway login --browserless
Browserless Login
Please visit: [URL]
Your pairing code is: salmon-enchanting-exploration
Unauthorized. Please login with `railway login`

Method 3: Token authentication

$ export RAILWAY_TOKEN="[valid-token-from-account-settings]"
$ railway whoami
Unauthorized. Please login with `railway login`
Note: Using RAILWAY_TOKEN environment variable

Additional Testing

Tested the token directly against the API:

$ curl -H "Authorization: Bearer [token]" \
  https://backboard.railway.app/graphql/v2 \
  -d '{"query":"query { me { id email } }"}' \
  -H "Content-Type: application/json"

Response: {"errors":[{"message":"Not Authorized"...}]}

What I've Tried

  1. ✅ Cleared all Railway config directories (~/.config/railway/, ~/.railway/)
  2. ✅ Reinstalled Railway CLI via npm
  3. ✅ Created multiple new tokens from Account Settings
  4. ✅ Tested with both binary and npm versions
  5. ✅ Verified network connectivity to Railway API
  6. ✅ Tested different authentication header formats

Expected Behavior

The CLI should successfully authenticate using a valid API token created from the Account Settings page.

Actual Behavior

All authentication methods fail with "Unauthorized" error, even with freshly created valid tokens.

Additional Context

  • I have an active paid Railway account
  • The same tokens work when logging into the Railway web dashboard
  • There appears to be a conflict between the binary installation and npm installation on the system

Any guidance on resolving this issue would be greatly appreciated.

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