## TL;DR

Upgrade the CLI past that fix; if you are pinned to an affected v3.x in the meantime, downgrade to v2.x as the temporary workaround. It had worked for months on the same setup; the reporter's temporary fix was pinning the CI to CLI v2.x.

## Steps

1. This was a v3.x CLI regression in how the token was handled in non-interactive environments - the CLI ignored the exported RAILWAY_TOKEN and demanded an interactive login. The Railway team investigated and fixed it in PR #387 (maintainer nebulatgs confirmed "Fixed in #387"). Upgrade the CLI past that fix; if you are pinned to an affected v3.x in the meantime, downgrade to v2.x as the temporary workaround. Note the confusing symptom: the deploy itself succeeds server-side, so only treat the exit code as the signal, and check your CLI version first when you see this. Source: https://github.com/railwayapp/cli/issues/324

## When to use

You are seeing this: In CI (GitHub Actions) and locally, railway up with RAILWAY_TOKEN exported started failing on CLI v3.x with: Error: Unauthorized. Use this skill when you run into "Railway CLI v3: "railway up" fails with "Unauthorized. Please login with railway login" despite RAILWAY_TOKEN".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

## Edge cases

- Note the confusing symptom: the deploy itself succeeds server-side, so only treat the exit code as the signal, and check your CLI version first when you see this.

## Sources

- https://github.com/railwayapp/cli/issues/324
