cli icon indicating copy to clipboard operation
cli copied to clipboard

CLI authentication fails with valid API token on Linux

Open anderson-ufrj opened this issue 1 month ago • 14 comments

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.

anderson-ufrj avatar Nov 21 '25 18:11 anderson-ufrj

This is interesting that normal CLI login is failing too, so it is not just an issue with API tokens. Some questions

  • Are you able to use the API token on railway.com/graphiql?
  • Is the token scoped to a specific workspace or global?

coffee-cup avatar Nov 21 '25 18:11 coffee-cup

Starting today we're having the same problem. In our case we use the environment variable to deploy from Gitlab CI.

Unauthorized. Please login with ``railway login`` Note: Using RAILWAY_TOKEN environment variable

Running image ghcr.io/railwayapp/cli:4.11.1, yesterday it worked fine.

Any idea on how to solve this?

onabitz-admin avatar Nov 26 '25 10:11 onabitz-admin

yes i got the same case today and how to solve it ?

rekafin avatar Nov 26 '25 11:11 rekafin

same from my side, It started today, got the issue on images 4.11.2, 4.11.1, 4.11.0

elina-israyelyan avatar Nov 26 '25 11:11 elina-israyelyan

same here, started today (deployment via gitlab using railway up)

OlgaMaslova avatar Nov 26 '25 12:11 OlgaMaslova

Same here, deployment via gh actions stopped working

Ventorius avatar Nov 26 '25 12:11 Ventorius

same here

butterflai-ai avatar Nov 26 '25 13:11 butterflai-ai

same :/

EnricRovira avatar Nov 26 '25 13:11 EnricRovira

same here

keisukee avatar Nov 26 '25 14:11 keisukee

same here

thedavgar avatar Nov 26 '25 14:11 thedavgar

I'm getting this error on GitHub Actions and locally (macOS).

hosmelq avatar Nov 29 '25 03:11 hosmelq

same here I got the same error on Mac M1 selicon

MefDev avatar Dec 07 '25 19:12 MefDev

Same here in GitHub Actions

SimonOsipov avatar Dec 09 '25 04:12 SimonOsipov

https://github.com/railwayapp/cli/issues/657#issuecomment-3509435265

Seems like the project-scoped token is the issue, when you have token without Scope and provide project ID - it is success

SimonOsipov avatar Dec 09 '25 08:12 SimonOsipov