Misleading "Invalid Token" Error in CLI / MCP Server due to Network/DNS Failure
dolunayozerennn
HOBBYOP

22 days ago

Hello Railway Team,

We are developing an AI agent ecosystem using the Model Context Protocol (MCP) and integrating it with the @railway/mcp-server to manage our projects autonomously.

We recently encountered a persistent authentication issue where the MCP server throws the following error: Railway CLI error: Invalid or expired Railway token. Please run 'railway login' to refresh your authentication

We verified multiple times that our RAILWAY_TOKEN (an active Account Token) is perfectly valid and properly passed into the environment.

Upon deeper debugging, we discovered the real root cause: Our AI sandbox environment has strict outbound DNS restrictions. When we try to reach the API directly, we get: dns error: failed to lookup address information: nodename nor servname provided, or not known (targeting backboard.railway.com)

The Issue / Feature Request: When the underlying Railway CLI (or the MCP wrapper) fails to authenticate the token because it cannot reach the Railway API due to a network/DNS error, it incorrectly swallows the network exception and defaults to throwing the "Invalid or expired Railway token" error message.

Could your engineering team improve the error handling in the CLI / MCP Server? If the authentication fails due to a network timeout or DNS resolution issue, it should explicitly report a network/connection error rather than misleading the user into thinking their token is invalid or expired. This would save a lot of debugging time for teams running CI/CD or sandboxed agents.

Thanks for the great product!

Solved

1 Replies

Status changed to Awaiting Railway Response Railway 22 days ago


22 days ago

Neither of those error messages appear in the CLI's codebase, so I am at a bit of a loss here.


Status changed to Awaiting User Response Railway 22 days ago


Railway
BOT

15 days ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 15 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...