Skip to main content

Introduction

This guide moves a Heroku app to Shard Cloud. Every part of a Heroku app has a direct counterpart: Things that get simpler:
  • $PORT keeps working. Every Shard Cloud container sets PORT=80, so an app that listens on process.env.PORT (or os.environ["PORT"]) needs no change. It must listen on 0.0.0.0, as on Heroku.
  • The disk is persistent. Unlike Heroku’s ephemeral filesystem, files your app writes under /app survive restarts (up to the storage limit).
  • No dyno sleeping. Apps run all the time and restart automatically if they crash.

Before You Start

What you need

  • The Heroku CLI, logged in to the account that owns the app
  • The app’s code (git clone of your repository, or heroku git:clone -a YOUR_APP)
  • A Shard Cloud account. Each Procfile process becomes an application, and each add-on database a database, so check that their RAM fits in your plan (see the minimums on the limits page)
  • To restore the database: Docker, or pg_restore installed locally

Take stock of the app

Run these from the code folder, replacing YOUR_APP:

Step 1: Export the Config Vars

heroku.env now holds every config var as KEY=value. Open it and:
  • Delete the ones the add-ons manage, such as DATABASE_URL, HEROKU_POSTGRESQL_*, REDIS_URL and REDIS_TLS_URL: you’ll set them to the new databases in step 4.
  • Leave everything else as it is.
heroku.env contains your secrets. Don’t commit it, and delete it when you’re done.

Step 2: Create the Databases

1

PostgreSQL

In the Dashboard, create a PostgreSQL database. Pick the same major version as Heroku’s (heroku pg:info) or a newer one: the version can’t change later. Give it at least as much room as the data needs (database storage grows with RAM, see limits).
2

Redis (if you use Heroku Redis)

Create a Redis database. Heroku Redis is usually a cache or a job queue, so it starts empty: there’s nothing to copy.
3

Copy the connection URLs

Each database’s page shows its connection URL. You’ll use them in steps 3 and 4.

Step 3: Move the Postgres Data

To keep the data consistent, put the Heroku app in maintenance mode first: heroku maintenance:on -a YOUR_APP. Writes made after the backup won’t be copied.
Capture a fresh backup and download it:
Restore it into the Shard Cloud database. Use a pg_restore of your Shard Cloud database’s major version, for example with Docker (postgres:17 for a PostgreSQL 17 database):
Or, with pg_restore installed locally:
--no-owner --no-acl drops Heroku’s roles and grants, which don’t exist on Shard Cloud. pg_restore may report errors about Heroku-specific objects (such as the heroku_ext schema or an extension that isn’t available); check that your tables and their row counts are all there:
Create a MySQL database, then copy the data with mysqldump and the mysql client:
Take the old values from the add-on’s URL (heroku config:get JAWSDB_URL -a YOUR_APP) and the new ones from the database page.
Create a MongoDB database, then copy the data with the MongoDB Database Tools:

Step 4: Set the Environment Variables

Add the new databases’ URLs to heroku.env, under the names your code reads:
heroku.env
You’ll import this file into each application in step 6.
Heroku Postgres requires SSL, so many apps already connect with ssl: { rejectUnauthorized: false } (Node) or sslmode=require. That keeps working: Shard Cloud databases only accept encrypted connections. To verify the certificate instead, see Verifying the Certificate.

Step 5: Translate the Procfile

Each line of the Procfile becomes one application, configured by a .shardcloud file. The start command goes in CUSTOM_COMMAND, and a release command goes in front of the web command, so it runs each time the app starts. Heroku runs your build (npm run build, collectstatic…) during the deploy. Shard Cloud installs the dependencies but doesn’t run a build, so put the build in the start command too.
Procfile
becomes, for the web process:
.shardcloud
Drop npm run build if your package.json has no build script. Dependencies are installed with npm, yarn, pnpm or bun, following your lockfile. Set VERSION to the Node.js major version in your engines field if it isn’t the recommended one.

Workers and other processes

A worker (or any process that doesn’t receive web traffic) is an application without SUBDOMAIN, so it needs only 256 MB:
.shardcloud
Give it the same environment variables as the web app. Run the release command in the web app only.

Heroku Scheduler

Shard Cloud has no job scheduler of its own. Run the jobs from a small application instead (or from your worker), with a scheduling library such as node-cron for Node.js or APScheduler for Python:
scheduler.js
Since applications restart automatically, the scheduler comes back by itself if it crashes.

Step 6: Deploy

1

Upload the web app

Add the web app’s .shardcloud to the root of your code, zip it without node_modules/, virtualenvs or build output (100 MB at most), and upload it in the Dashboard.
2

Import the environment variables

On the application’s page, open Environment Variables, choose Import .env and pick heroku.env. Check the values, then restart the application.
3

Repeat for each other process

Upload the same code with that process’s .shardcloud (no SUBDOMAIN), and import the same heroku.env.
4

Connect GitHub (optional)

To deploy on every push, like Heroku’s GitHub integration, connect each application to your repository on its Deploy page. See Git integration.
A .shardcloud file in your repository is applied to every application deployed from it. With a web app and a worker on the same repository, keep .shardcloud out of the repository (add it to .gitignore) and let each application keep the one it was uploaded with.

Step 7: Test, Then Switch the Domain

1

Test on the free subdomain

Open https://myapp.shardweb.app, log in, and check pages that read and write data. Check the workers’ logs on their pages.
2

Add your domain

Add your domain to the web app and point its DNS at Shard Cloud, replacing the Heroku DNS target. See Custom Domain. HTTPS is set up for you.
3

Shut down Heroku

Once traffic is on Shard Cloud and you’ve checked the data, scale the Heroku dynos to zero (heroku ps:scale web=0 worker=0 -a YOUR_APP). Keep the Heroku database until you’re sure nothing is missing, then remove the add-ons to stop the charges.

Troubleshooting

The server must listen on 0.0.0.0 and on $PORT (80). A hardcoded port such as 3000 or 5000, or listening on localhost only, makes the site unreachable.
Use python -m gunicorn (or python -m celery, python -m uvicorn) 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.
The pg_restore you used is older than Heroku’s Postgres. Use a newer one, for example the postgres:17 or postgres:18 Docker image.
Environment variables are read when the app starts: restart the application after changing them.