Move from Railway
Moving a Railway service to velixir takes four steps: deploy your code, bring its variables, move the database, and switch the domain. Railway and velixir both build from your source without a Dockerfile, so most services move with no code changes.
Before you start
- Install the velixir CLI and run
velixir login. - Have the Railway CLI signed in and linked to the project (
railway link), and the Postgres client tools (pg_dump,pg_restore,psql) installed locally. - Pick a quiet window for the database copy. Writes made on Railway after the dump won't be carried over.
1. Create the app and deploy it
From your service's source directory:
velixir init
velixir deploy
velixir detects the language and builds the app. Your app must listen on 0.0.0.0 on the port in PORT, which Railway services already do.
- Start command. A
startCommandinrailway.jsonorrailway.tomlgoes in aProcfileasweb: <command>. - Pre-deploy command. Run migrations as part of your start command, before the server starts.
- Cron schedules. Run them from inside your app with a cron library, or from a small worker app.
- Several services in one project. Deploy each one as its own velixir app from its own folder.
- Dockerfile. velixir builds from source and doesn't use it. If yours installs extra system packages, open a ticket and we'll help.
2. Bring your variables
Print the service's variables as KEY=value lines and pipe them straight in:
railway variables --kv | velixir env import - --secret
Or open the service's Variables tab, switch to the Raw Editor, and copy it as .env or JSON into Import on the app's Environment tab. Both shapes are read.
Railway references such as ${{Postgres.DATABASE_URL}} aren't values; Railway fills them in when it deploys. The import stops at the first one and names it, so nothing half-imports. Remove those lines, and bind a velixir database and cache instead (below), which set DATABASE_URL and REDIS_URL for you. Moving is a good moment to rotate your keys, so paste fresh ones where you can. See Environment variables.
3. Dump your Railway database
Your Railway Postgres service has a DATABASE_PUBLIC_URL variable. Copy it from that service's Variables tab, then:
pg_dump -Fc --no-acl --no-owner "<DATABASE_PUBLIC_URL>" > latest.dump
Move your Postgres data
Create the database on velixir in the same project as the app, from the dashboard or with
velixir db create. Pick a plan with room for your data, and the same Postgres major version you run today or a newer one (15, 16 and 17 are available). Leave External access on so you can restore from your machine.Get its public connection string:
velixir db connect <database-id> --externalOr copy the External connection string from the database's page in the dashboard.
Restore your dump into it:
pg_restore --no-owner --no-acl --verbose -d "<velixir external connection string>" latest.dump--no-owner --no-aclmatter: your database's role owns everything it creates but isn't a superuser, so ownership and grants from the old host can't be replayed. An extension that needs a superuser to install may fail to restore; tell us which and we'll help.Bind the database to your app from the database's page in the dashboard, or with
velixir db bind <database-id> --app <app-id>. The app then getsDATABASE_URLpointing at the in-cluster address. Remove anyDATABASE_URLyou imported from the old host first, or your value wins over the binding.
The connection passes straight through to Postgres, encrypted end to end. If a single step (a large index build, say) runs for more than five minutes without sending anything, the connection can drop. For big databases, restore in parts (pg_restore --section=pre-data, then data, then post-data), or open a ticket and we'll help you run it.
Redis
Create a Valkey cache from the dashboard or with velixir cache create, and bind it to the app. Valkey speaks the Redis protocol, so Redis clients work unchanged.
Volumes
Add a persistent volume to the app and copy your files across.
4. Switch the domain
Redeploy with velixir deploy, check the app on its velixir.run address, then add your domain on the app's Domains tab and point DNS at velixir. See Custom domains. Keep the Railway service running until DNS has moved over.
Moving a bill over too? The switching offer covers your current hosting bill as credit for your first three months.