Introduction
This guide moves a Railway project to Shard Cloud. Each Railway service becomes a Shard Cloud project:
Things that stay the same:
PORTkeeps working. Railway tells your app which port to use throughPORT, and so does Shard Cloud: every container setsPORT=80. An app that listens onprocess.env.PORT(oros.environ["PORT"]) on0.0.0.0needs no change.- Always on. Apps run all the time, with no sleeping, and restart automatically if they crash.
Before You Start
What you need
- The Railway CLI, logged in (
railway login) and linked to the project (railway linkin the code folder) - The code of each service
- A Shard Cloud account with room for every service and database (see the minimum RAM of each on the limits page)
- To copy databases: Docker, or the database’s own tools installed locally
Take stock of the project
Open the project canvas on Railway and note, for each service:- Its source (repository and root directory, or
Dockerfile), and whether it has a public domain - Its Custom Build Command, Pre-deploy Command, Custom Start Command and Cron Schedule (in the service’s Settings, or in
railway.json/railway.toml) - Any volume and its mount path
- Which services call each other through
.railway.internaladdresses
Step 1: Export the Variables
For each service, print its variables with references already resolved:- Delete the ones Railway adds: every
RAILWAY_*variable (RAILWAY_PUBLIC_DOMAIN,RAILWAY_PRIVATE_DOMAIN,RAILWAY_ENVIRONMENT…). - Delete the database URLs (
DATABASE_URL,REDIS_URL,MONGO_URL,MYSQL_URL…): you’ll set them to the new databases in step 4. - Replace
.railway.internaladdresses with the other app’s Shard Cloud address,https://other-app.shardweb.app(see the warning above).
Step 2: Create the Databases
In the Dashboard, create a database for each one on Railway, of the same type. Pick the same version as on Railway or a newer one: the version can’t change later. Each database’s page shows its connection URL, which you’ll use in steps 3 and 4.Step 3: Move the Data
Railway databases accept outside connections through their public URL:DATABASE_PUBLIC_URL, MYSQL_PUBLIC_URL, MONGO_PUBLIC_URL or REDIS_PUBLIC_URL in the database service’s variables. The non-public URLs only work inside Railway.
- PostgreSQL
- MySQL
- MongoDB
- Redis
Dump with Then check that your tables and their row counts are all there:
pg_dump and restore with pg_restore, using the Docker image of your Shard Cloud database’s major version (postgres:17, postgres:18):Step 4: Set the Environment Variables
Add the new databases’ URLs to each service’s.env file, under the names its code reads:
your-service.env
Shard Cloud databases only accept encrypted connections. Most drivers handle this with the connection URL alone; if yours connects without TLS by default, turn it on (for example
ssl: { rejectUnauthorized: false } in Node’s pg, or sslmode=require).Step 5: Translate Each Service
Each service becomes one application, configured by a.shardcloud file. Railway builds your app (Railpack or Nixpacks run npm run build and the like) before starting it; Shard Cloud installs the dependencies but doesn’t run a build, so put the build in the start command. A pre-deploy command (usually migrations) goes in front of it, so it runs each time the app starts.
- Node.js
- Python
- Dockerfile
- Static site
A service with the pre-deploy command Drop
npx prisma migrate deploy and the start command npm start becomes:.shardcloud
npm run build if package.json has no build script. Dependencies are installed with npm, yarn, pnpm or bun, following your lockfile. Set VERSION to your Node.js major version (the engines field, or .nvmrc) if it isn’t the recommended one.Workers
A service with no public domain (a queue worker, a bot) is an application withoutSUBDOMAIN, so it needs only 256 MB:
.shardcloud
Cron services
On Railway, a service with a Cron Schedule starts on the schedule, runs, and exits. Shard Cloud has no job scheduler of its own: run the job from a small, always-on application with a scheduling library such as node-cron (or APScheduler for Python), using the same schedule. Railway’s cron schedules are in UTC:scheduler.js
Volumes
Each application has a persistent/app folder (the code’s own folder; see the size on the limits page) whose files survive restarts and deploys. A Railway volume mounted at another path (such as /data) becomes a folder inside the app: point your code at it, for example DATA_DIR=/app/data.
To bring the files over, copy them out of the Railway service (for example with railway ssh into the service and tar, if its image has them), then upload them to the application with its file manager in the dashboard, or include them in the ZIP.
Monorepos
On Railway, a service can build from a subfolder of the repository (its Root Directory). On Shard Cloud, an application’s files are the whole upload: zip each service’s folder on its own, with its.shardcloud at the root of the ZIP.
Step 6: Replicas (Optional)
Railway’s replicas become copies of the application: create the same app more than once and put the copies behind a load balancer (Pro plan and above), which splits the traffic between them and skips a copy that is down.Step 7: Deploy
1
Upload each application
Zip each service’s code with its
.shardcloud at the root, without node_modules/, virtualenvs or build output (100 MB at most), and upload it in the Dashboard.2
Import the environment variables
On each application’s page, open Environment Variables, choose Import .env and pick that service’s file. Check the values, then restart the application.
3
Connect GitHub (optional)
To deploy on every push, like Railway does, connect each application to its repository and branch on its Deploy page, and turn on Auto-Restart on Deploy. See Git integration.
Step 8: Test, Then Switch the Domain
1
Test on the free subdomain
Open
https://myapi.shardweb.app and check the pages and routes that read and write data. Check the workers’ logs on their pages, and that services that used to call each other privately now reach each other through their public addresses.2
Add your domain
Add your domain to the application and point its DNS at Shard Cloud, replacing Railway’s CNAME. See Custom Domain. HTTPS is set up for you.
3
Shut down Railway
Once traffic is on Shard Cloud and you’ve checked the data, remove the services on Railway. Keep the Railway databases until you’re sure nothing is missing, then delete them, and their volumes, to stop the charges.
Troubleshooting
The app starts but the site doesn't load
The app starts but the site doesn't load
The server must listen on
0.0.0.0 and on $PORT (80). A hardcoded port, or listening on localhost only, makes the site unreachable.A service can't reach another one
A service can't reach another one
.railway.internal addresses don’t exist on Shard Cloud. Use the other application’s public address (https://other-app.shardweb.app). Only HTTP on port 80 is reachable; other ports need a VPS.gunicorn: not found (or uvicorn, celery)
gunicorn: not found (or uvicorn, celery)
Use
python -m gunicorn (or python -m uvicorn, python -m celery) in CUSTOM_COMMAND.Out of memory during the build
Out of memory during the build
The build runs when the app starts, inside the app’s RAM. Raise
MEMORY (1024 MB is a safe start for frontend builds) or build locally and upload the built files.Can't connect to the Railway database to dump it
Can't connect to the Railway database to dump it
Use the database’s public URL (
DATABASE_PUBLIC_URL and similar). The private URL only works from inside Railway.Changed an environment variable and nothing happened
Changed an environment variable and nothing happened
Environment variables are read when the app starts: restart the application after changing them.