Deploying Tally on Railway
Tally runs on Railway as two services: the tally container (from the published Docker image) and Railway's managed Postgres. There is no volume on tally; everything lives in Postgres, and the GeoIP database ships inside the image.
Railway's
railway.json/railway.tomlconfig-as-code is deprecated (it can't be enabled on new services and stops working for existing ones on 2027-01-01), so Tally doesn't ship one. One-click deploys use a Railway template, which you create once in the dashboard.
The official image is ghcr.io/waymark-labs/tally. If you fork Tally and publish your own image, use its name instead.
Option A: deploy from the template (recommended)
If the README has a "Deploy on Railway" button, click it. The template creates both services with every variable below already filled in. After the deploy finishes:
- Open the
tallyservice → Settings → Networking and confirm it has a public domain (the template generates one). - Visit the domain right away and finish setup (create the owner and your first site). Until you do, anyone who finds the URL could claim the instance. To lock it down first, set
TALLY_SETUP_TOKENon the service; the setup form then asks for it. - Copy the snippet from Site settings → Tracking into your site.
Option B: set it up by hand
New project → Deploy a Docker image:
ghcr.io/waymark-labs/tally:latest. Rename the service totally.New → Database → PostgreSQL. Railway names it
Postgres.On
tally→ Variables, add:APP_ENV=production APP_URL=https://${{RAILWAY_PUBLIC_DOMAIN}} DATABASE_URL=${{Postgres.DATABASE_URL}} TALLY_SECRET=<a long random string, e.g. openssl rand -hex 32>Settings → Networking → Generate Domain (port 8000 is detected from the image's
EXPOSE; Railway also injectsPORT, which Tally honors).Settings → Deploy → Healthcheck Path:
/up.Leave Replicas at 1 (see "Scaling" below) and don't attach a volume.
Deploy. Migrations run automatically when the container starts.
Use a custom domain? Add it under Networking, then change APP_URL to it. Tally rejects requests for hosts other than APP_URL's host and its subdomains; to accept more hosts, list them in TALLY_TRUSTED_HOSTS.
Creating the template (one-time, for maintainers)
Do this from a project that you set up with Option B and verified works.
In the project, open the ⋯ menu (top right) → Generate Template from Project. (Alternatively: Workspace → Templates → New Template and add the two services yourself.)
For the
tallyservice:Source: Docker image
ghcr.io/waymark-labs/tally:latest.Variables (use these exact values so nobody has to type anything):
Variable Value APP_ENVproductionAPP_URLhttps://${{RAILWAY_PUBLIC_DOMAIN}}DATABASE_URL${{Postgres.DATABASE_URL}}TALLY_SECRET${{secret(64, "abcdef0123456789")}}TALLY_SETUP_TOKEN(optional) leave out, or ${{secret(24)}}and tell users to read it from the Variables tabNetworking: enable a public HTTP domain on port
8000.Healthcheck path
/up; no volume; 1 replica.
For the
Postgresservice keep Railway's defaults (its volume holds all of Tally's data).Fill in the template's name ("Tally"), description, icon, and the README link, then Publish. Copy the template URL.
Add the button to the README:
[](https://railway.com/new/template/<template-code>)Test it: deploy the template into a fresh project, open the domain, finish setup, add the snippet to a test page, and check that a visit shows up with the right country (this confirms
X-Forwarded-Forhandling behind Railway's proxy).
The template tracks :latest. When a new release is published, users redeploy the tally service (Deployments → Redeploy) to pull it.
Why these settings
TALLY_SECRETinstead ofAPP_KEY: the framework needsAPP_KEY=base64:<32 bytes>, which Railway'ssecret()function can't produce. Tally derivesAPP_KEYfromTALLY_SECRETat boot. ChangingTALLY_SECRETlater signs everyone out.- Leave
TALLY_TRUSTED_PROXIESunset. The default trusts private and CGNAT (100.64.0.0/10) addresses, where Railway's edge proxy is expected to connect from, and Tally uses the right-mostX-Forwarded-Forentry that isn't a trusted proxy, so visitors can't spoof their address. Unverified on live Railway: after the first deploy, open Settings → System and check "Your IP as Tally sees it". If it shows a private address, setTALLY_TRUSTED_PROXIES=*as a fallback (then the left-most entry is used, which a visitor can spoof for their own geo lookup and rate-limit bucket). - No volume on
tally: sessions, cache, rate limits, and analytics are all in Postgres; GeoIP data is in the image. Logs go to stderr (Railway's log viewer). - Migrations in the entrypoint: the container runs
./app migrate --forcebefore it starts serving, so no pre-deploy command is needed. SetTALLY_SKIP_MIGRATIONS=trueto turn that off.
Scaling and sizing
One replica on the smallest plan handles well over 10 million events a month. Background work (flushing the ingest buffer, rollups, partition maintenance) runs inside the web process. Two replicas work, but each keeps its own buffer and visit cache, so a visitor whose requests land on different replicas can be split into two visits. Prefer a bigger single instance.
Storage: roughly 3 GB of Postgres per 10 million events with indexes. Set TALLY_RETENTION_MONTHS to drop old raw months (aggregated dashboards keep working forever).
Backups
Railway's Postgres has backups in Database → Backups. You can also run pg_dump against the public connection string from the Postgres service's Connect tab.
Troubleshooting
- Healthcheck fails: open the deploy logs. A missing
DATABASE_URLorTALLY_SECRETstops the container with a clear error. - 400 Bad Request on every page:
APP_URLdoesn't match the domain you're visiting. FixAPP_URLor add the host toTALLY_TRUSTED_HOSTS. - Everyone shows the same country: check Settings → System ("Your IP as Tally sees it"). If it shows a private address, Railway's proxy isn't in the trusted ranges; set
TALLY_TRUSTED_PROXIES=*. - Run a command:
railway sshinto the service (or use the service shell) and run./app tally:doctor.