CLI authentication fails with valid API token on Linux
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)
- 4.11.0 (binary from
- Node.js: v20.19.4
- npm: 9.2.0
Steps to Reproduce
- Created a new API token from https://railway.app/account/tokens
- 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
- ✅ Cleared all Railway config directories (
~/.config/railway/,~/.railway/) - ✅ Reinstalled Railway CLI via npm
- ✅ Created multiple new tokens from Account Settings
- ✅ Tested with both binary and npm versions
- ✅ Verified network connectivity to Railway API
- ✅ 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.
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?
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?
yes i got the same case today and how to solve it ?
same from my side, It started today, got the issue on images 4.11.2, 4.11.1, 4.11.0
same here, started today (deployment via gitlab using railway up)
Same here, deployment via gh actions stopped working
same here
same :/
same here
same here
I'm getting this error on GitHub Actions and locally (macOS).
same here I got the same error on Mac M1 selicon
Same here in GitHub Actions
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