Skip to main content

Introduction

This guide moves a Railway project to Shard Cloud. Each Railway service becomes a Shard Cloud project: Things that stay the same:
  • PORT keeps working. Railway tells your app which port to use through PORT, and so does Shard Cloud: every container sets PORT=80. An app that listens on process.env.PORT (or os.environ["PORT"]) on 0.0.0.0 needs no change.
  • Always on. Apps run all the time, with no sleeping, and restart automatically if they crash.
Services can’t talk over a private network. On Railway, services reach each other at <service>.railway.internal on any port. On Shard Cloud, an application reaches another application only through its public address (https://other-app.shardweb.app or its domain), and only over HTTP on port 80. Databases are different: apps reach them through their connection URL, over Shard Cloud’s private network. A service that needs other ports (a game server, a message broker such as RabbitMQ, anything behind a Railway TCP proxy) belongs on a VPS.

Before You Start

What you need

  • The Railway CLI, logged in (railway login) and linked to the project (railway link in 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.internal addresses

Step 1: Export the Variables

For each service, print its variables with references already resolved:
Open each file and:
  • 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.internal addresses with the other app’s Shard Cloud address, https://other-app.shardweb.app (see the warning above).
These files contain your secrets. Don’t commit them, and delete them when you’re done.

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.
To keep the data consistent, stop the services that write to the database before you copy it. Writes made after the dump won’t be copied.
Dump with pg_dump and restore with pg_restore, using the Docker image of your Shard Cloud database’s major version (postgres:17, postgres:18):
Then check that your tables and their row counts are all there:

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
You’ll import each file into its application in step 7.
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.
A service with the pre-deploy command npx prisma migrate deploy and the start command npm start becomes:
.shardcloud
Drop 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.
For other languages, see the guide for your language: Go, Ruby, PHP, Java, Elixir or C#.

Workers

A service with no public domain (a queue worker, a bot) is an application without SUBDOMAIN, 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.
A .shardcloud file in your repository is applied to every application deployed from it. With several applications on the same repository (a monorepo, or an API and a worker), keep .shardcloud out of the repository (add it to .gitignore) and let each application keep the one it was uploaded with.

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 server must listen on 0.0.0.0 and on $PORT (80). A hardcoded port, or listening on localhost only, makes the site unreachable.
.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.
Use python -m gunicorn (or python -m uvicorn, python -m celery) in CUSTOM_COMMAND.
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.
Use the database’s public URL (DATABASE_PUBLIC_URL and similar). The private URL only works from inside Railway.
Environment variables are read when the app starts: restart the application after changing them.