Keep your app's data in Railway Postgres
In shortThe Railway connector does two separate things. With an API token, project ID and environment ID it lets you deploy the app to Railway. Add your Railway Postgres public connection string too, and MonstarX moves the app's tables and rows there, checks them, and rewrites the app to use it. Move back brings the data home.
Railway is a cloud platform for running apps and databases. MonstarX’s Railway connector links one of your apps to your Railway project, for one or both of two jobs:
- Keep the app’s data in Railway Postgres — your own Postgres database in Railway, instead of MonstarX’s. This page explains it.
- Deploy the app to Railway — run it on your Railway project from its GitHub repository. See Publish to other hosts.
The two are independent: your data can live in Railway Postgres while the app is published on MonstarX, and the other way round.
When should I use Railway Postgres?
Section titled “When should I use Railway Postgres?”Choose it when you already run things on Railway, want the app’s data in your own account, or want to reach it with your own database tools. Otherwise MonstarX’s own database needs no setup at all — see Your app’s database.
An app keeps its data in one place at a time. Moving to Railway Postgres is a move, not a copy.
Before you start
Section titled “Before you start”In Railway:
- Open (or create) a Railway project and pick the environment to use, usually production.
- Add a Postgres database service to it and turn on its public networking, so MonstarX can reach it.
- Create an account or workspace API token in Railway’s Account Settings → Tokens. A project token cannot create services, so it will not work.
In MonstarX, the app’s data must be in MonstarX’s own database. If it is in Supabase or Firestore, move it back first.
How do I move my app’s data to Railway Postgres?
Section titled “How do I move my app’s data to Railway Postgres?”-
Open your project and click Backend in the top bar, then Cloud.
-
Under Connectors, click Connect beside Railway — or choose Railway (Postgres) in Where this app keeps its data.
-
Fill in the form:
- Account or workspace API token — the token from Railway.
- Project ID — from your Railway project’s settings.
- Environment ID — from the same settings.
- Postgres public connection string (optional) — your Postgres service’s
DATABASE_PUBLIC_URL. This is what starts the move; leave it empty if you only want to deploy to Railway.
-
Click Connect Railway. MonstarX checks that the environment belongs to the project, and that it can create tables in the database.
-
A card appears in the chat: Move this app’s data to Railway Postgres, with how many tables and rows it found. Click Move my app.
-
The card shows each step — reading the data, creating the tables, copying the rows, checking everything arrived, pointing the app at Railway, rewriting the app’s code — and ends with Your app now runs on Railway.
The Database card in BackendCloud then says On Railway.
What happens to my data?
Section titled “What happens to my data?”- Every table and row goes into your Railway Postgres database, and MonstarX counts both sides before it switches over. If the counts do not match, the move stops and the app is left as it was.
- MonstarX keeps its previous copy, untouched, so you can move back.
- The app’s code is rewritten for Postgres in a build request MonstarX sends itself.
- While the move runs, new requests wait in the queue, and Stop on the card stops it.
Can I move back?
Section titled “Can I move back?”Yes. Click Move back on the Database card in BackendCloud and confirm. MonstarX copies everything back into its own database and rewrites the code again. Your Railway database is left as it is.
Good to know
Section titled “Good to know”- The token stays with MonstarX. The API token, project ID and environment ID are stored encrypted and used only by MonstarX to manage Railway. They never go into your app.
- The connection string goes to the app’s server only, and only after the switch. It never reaches the browser.
- You cannot disconnect Railway, or change its database, while the app uses it. Move back first.
- Unpublishing from Railway removes only the service MonstarX created, never your Postgres database.
- Imported apps keep their own database code: MonstarX hands them the connection string as
RAILWAY_DATABASE_URLbut does not move their data. - A private Railway address will not work. MonstarX needs the public connection string to reach the database.
Frequently asked questions
Section titled “Frequently asked questions”Do I need to deploy to Railway to use Railway Postgres?
No. The two are independent. Your app can keep publishing on MonstarX while its data lives in Railway Postgres.
Which connection string do I paste?
The Postgres service's DATABASE_PUBLIC_URL, after turning on public networking for it. A private network address cannot be reached from MonstarX.
Why was my token refused?
Railway project tokens cannot create services. Make an account or workspace token in Railway's Account Settings → Tokens instead.
Can I switch from Supabase to Railway?
Yes, in two moves: use Move back to bring the data to MonstarX's database, then connect Railway Postgres.
Will my users need to sign up again?
No. Accounts are rows in your app's database, so they move with the rest of the data and keep working.