How to back up a Railway Postgres database to Windows

A logical dump is the one backup that survives deleting the Railway project. Here's how to take one from Windows, through the TCP proxy or the CLI tunnel.

Updated October 14, 2026 · 2 min read

Short on time? PostgresBackup does everything on this page from a Windows app: scheduled pg_dump backups, retention and one-click restores. Download it free.

Railway's PostgreSQL template runs Postgres in a service with a volume, and Railway offers backups of that volume depending on your plan. Those live inside Railway, and they go with the project. A pg_dump file on your own disk survives a deleted project, an account problem or a move to another host. Railway's own docs recommend keeping copies outside Railway too.

Step 1: Find the public connection string

Open your Postgres service in the Railway dashboard → Variables. You'll see two URLs:

  • DATABASE_URL uses Railway's private network (postgres.railway.internal). It only works from other services in the same project.
  • DATABASE_PUBLIC_URL goes through Railway's TCP proxy, something like postgresql://postgres:…@shuttle.proxy.rlwy.net:43125/railway. Use this one from your PC.

The proxy port is a random high number, not 5432. If there's no public URL, enable the TCP proxy under the service's Settings → Networking.

Step 2: Back it up

Take the pieces from DATABASE_PUBLIC_URL:

PowerShell
$env:PGPASSWORD = 'the-password-from-the-url'   # for a one-off test only
& 'C:\Program Files\PostgreSQL\18\bin\pg_dump.exe' -h shuttle.proxy.rlwy.net -p 43125 -U postgres `
    -F c -f "D:\Backups\railway-$(Get-Date -Format yyyyMMdd-HHmm).dump" railway
Remove-Item Env:PGPASSWORD

The default database is called railway. Use client tools at least as new as the Postgres version your template runs (check with SELECT version();).

Alternative: the Railway CLI tunnel

With the Railway CLI installed and the project linked, railway connect postgres --tunnel-only opens a local tunnel to the database. Point pg_dump at the local port it prints. This avoids the public proxy entirely, but the CLI has to be signed in and running at backup time, so it suits one-off dumps better than schedules.

Step 3: Schedule it

Use the script from the main Windows guide:

PowerShell
$Database  = 'railway'
$PgHost    = 'shuttle.proxy.rlwy.net'
$Port      = 43125
$User      = 'postgres'

and in pgpass.conf:

Config
shuttle.proxy.rlwy.net:43125:railway:postgres:YOUR_PASSWORD

If you regenerate the TCP proxy or rotate the database password in Railway, the host, port or password changes. Update the script and the password file, or the next backup fails. The log will say could not connect or password authentication failed.

When the proxy misbehaves

Some users report that the public proxy occasionally drops long-running connections. If dumps of a large database fail partway, try in this order: regenerate the proxy (Settings → Networking), use the CLI tunnel, or run pg_dump from a small service inside the same Railway project over the private URL and ship the file out to storage.

Restoring

PowerShell
& "$bin\createdb.exe" -h localhost -U postgres railway_copy
& "$bin\pg_restore.exe" -h localhost -U postgres -d railway_copy --no-owner --no-privileges D:\Backups\railway-20261014-0200.dump

To restore into Railway, run the same pg_restore against DATABASE_PUBLIC_URL's host and port. See restoring a .dump file on Windows.

How PostgresBackup handles Railway

Paste DATABASE_PUBLIC_URL into PostgresBackup's connection string box. It splits out the proxy host, port, user and database for you. Create a nightly job and the background service handles the rest. If Railway changes the proxy address, Backup History shows the failed run, and you only need to update the server entry once.

The shortcut

Rather not maintain a backup script?

PostgresBackup is a Windows app that does all of this for you, with nothing to script and nothing to remember.

  • Scheduled pg_dump backups from a background service that starts with Windows
  • Keep the last N files plus hourly, daily, weekly, monthly and yearly copies
  • Restore any backup, or clone a database to another server, in a few clicks
  • PostgreSQL client tools included; standard .dump files, no lock-in
  • No account, no subscription, nothing leaves your machine

Clones, restores and manual backups are free. Scheduled backups are free for 14 days, then $9.99 once (launch price; $24 from January 1).