a month ago
Hello Railway Support,
I’m encountering persistent unauthorized errors when deploying via the CLI with a token.
Steps to Reproduce
railway logout && rm -rf ~/.config/railway(to clear state)export RAILWAY_TOKEN="$(printf %s "<TOKEN>")"railway whoamirailway up -v
Expected Result
railway whoamishould succeed (for user token) andrailway upshould deploy successfully.For a deploy token,
railway upshould work in a linked directory.
Actual Result
railway whoami→unauthorizedrailway up→unauthorized(no additional actionable detail)
Troubleshooting Tried
Cleared auth state:
railway logoutand removed~/.config/railwayEnsured token has no trailing newline (used
printf), verified env var presentUpdated CLI to latest and re-tested
Verified project link:
.railway/project.jsonpresent (railway link <PROJECT_ID>)Selected environment/service explicitly:
railway environment <ENV>andrailway up --service <SERVICE>Checked system time sync and disabled proxy/mitm temporarily
When I use railway login everything works fine.
Questions
Is it expected that deploy/service tokens return
unauthorizedforwhoami? (If so, can you confirm the minimal required context forrailway upto succeed with such tokens?)Can you verify on your side whether this token is valid/not revoked and mapped to the project/environment above?
Are there any recent permission/scope changes to tokens that could cause this behavior?
Happy to provide additional logs or run any debug builds if helpful.
Thanks in advance!
6 Replies
a month ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
a month ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • about 1 month ago
a month ago
Is this a project token or an account token?
Whoami doesn't work with project tokens:
https://docs.railway.com/guides/cli
Can you try passing the token manually?
RAILWAY_TOKEN=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX railway up
Just to check if for any reason the var is not taken if exported?
a month ago
I tried both, adding to the action env var and also the inline declaration; neither is working.
a month ago
hey, so your errors are happening bc you're incorrectly passing the RAILWAY_TOKEN, it should be RAILWAY_API_TOKEN for whoami (for your steps to reproduce). try exporting the token directly in shell
export RAILWAY_API_TOKEN=XXXXXXXXXX
railway whoami
npx railway up --service <SERVICE_NAME> or railway up --service <SERVICE_NAME>
23 days ago
I am getting Unauthorized for a freshly created token. RAILWAY_API_TOKEN=xxxxxxxx railway whoami
(no RAILWAY_* env var set)
15 days ago
Any update here ?
