8 days ago
Hi Railway team,
We need to run a logical backup (pg_dump) from GitHub Actions against a production Postgres without enabling a public TCP proxy. We want to use a private SSH tunnel and the least-privilege credential supported.
Setup:
- Railway CLI 5.71.0
- GitHub Actions runner: ubuntu-24.04
- A project token created in Project Settings → Tokens, scoped to production and supplied as RAILWAY_TOKEN.
What we observed:
- A direct API request using the Project-Access-Token header and query { projectToken { projectId environmentId } } returned HTTP 200, with the expected project and environment IDs.
- Immediately afterward, railway connect Postgres –tunnel-only failed within approximately two seconds. Our wrapper classified the CLI error as “unauthorized”, but did not retain the raw output, so the exact message and failing API operation are unknown.
- The ephemeral SSH key had been generated but had not yet been registered. No tunnel opened.
The project token passed the direct API check. We therefore want to understand the supported authentication method before creating more tokens or repeating tests.
Questions:
- Is railway connect –tunnel-only supported with a project token (RAILWAY_TOKEN)?
- Does this command require access to account-level SSH keys that a project token cannot provide?
- What is the recommended least-privilege method for running pg_dump from CI against a private-network Postgres without enabling a public TCP proxy?
- If a workspace API token is required, can it be restricted to one project/environment or made read-only?
- Are native volume backups or PITR backups exportable as files, or only restorable within Railway?
We have paused further tests and will not widen permissions until the supported approach is clear.
Project/environment IDs and execution timestamps are available privately to Railway staff upon request. We will not share token values or database credentials.
Thank you.
1 Reply
8 days ago
railway connect --tunnel-only always tunnels over SSH, and SSH requires a key registered with your Railway account or workspace. SSH key management isn't supported with project tokens (RAILWAY_TOKEN). It needs a workspace-scoped RAILWAY_API_TOKEN or railway login, so a project token alone can't register the key needed to open the tunnel. See railway connect and railway ssh.
A workspace token has access to all of that workspace's resources, so it isn't limited to one project or environment. When the CLI uses one, it manages workspace-owned SSH keys, and those keys grant SSH access to every service in the workspace. Adding or removing workspace keys also requires workspace Admin access. Project tokens are the only token type scoped to a single environment in one project (token types).
The documented volume backup and PITR commands create, list, lock, delete and restore backups within Railway (railway postgres). For a portable file you can keep outside Railway, use pg_dump against the database.
Status changed to Awaiting User Response Railway • 8 days ago
16 hours 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 • about 16 hours ago