Skip to main content
Back to Blog
InfrastructureAI

Leaving Railway After the Breach: How I Moved Everything to Hetzner and Coolify for $40 a Month

7 min read
$40, monthly hosting after leaving Railway, down from $185
In this article
  1. 01What the attacker did with my key
  2. 02What Railway pays for, and what it does not
  3. 03Why I left anyway
  4. 04Railway vs Hetzner and Coolify: the real numbers
  5. 05How the migration went
  6. 06What I would do differently

In October, Railway was breached. An attacker got into its build system, worked their way to the credential that decrypts customer secrets, and decrypted environment variables for up to 1.85% of workspaces, about 100,000 of them. Railway's incident report (opens in new tab) walks through the whole chain.

Mine was one of them. Two days later, my Google Cloud bill showed $157 of Gemini usage for a day where I expected about $2.

This article is about what came after: what Railway does and does not pay for, why I left, and how I moved everything to two servers for about $40 a month. If you are thinking about leaving Railway, the migration section is the useful part.

What the attacker did with my key

The attacker was hunting for AI keys. My product, Rankioz, only calls one cheap Gemini model. The stolen key was used on Google's most expensive models at the priority tier, which my code has never called. My own logs showed 7,204 calls from October 1 to 24, all to the one model I use.

Total damage: $532.23 in usage plus $106.45 in VAT. Google refunded all of it, VAT included. That took about two weeks, a support case, and a lot of screenshots.

What Railway pays for, and what it does not

Railway's compensation policy (opens in new tab) is decent as far as it goes. If an AI provider will not refund usage on a key stolen in the breach, Railway pays it out of its own funds. Across all customers, that is at least $740K in stolen AI usage. Google refunded mine, so under that policy Railway owed me nothing.

Everything else is on you. Rotating every key in every project, auditing which secrets were exposed, fighting the billing case: none of that is covered. Railway's terms of service (opens in new tab) exclude "business interruption" and "work stoppage" outright and cap everything else at the greater of $100 or what you paid them in the previous twelve months.

I asked for $500 toward the cleanup. It took three emails and four weeks to get a no.

Why I left anyway

Honestly, I should have left a long time ago.

I was paying Railway about $185 a month for my own products, two client apps, and a pile of side projects. I never looked at that bill closely. When I finally did, the biggest line was Rankioz's background worker at $63 a month. It was running 16 processes, most of them sitting idle. One setting change took it down to 2 and cut about $55 a month.

That is what Railway is good at: everything just works, so you stop paying attention. The breach made me sit down and plan it properly. What does each project actually need, what should it cost, and where should it run?

Railway vs Hetzner and Coolify: the real numbers

I moved everything to two Hetzner Cloud (opens in new tab) servers in Europe, both running Coolify (opens in new tab), an open-source dashboard that deploys from GitHub much like Railway does.

RailwayHetzner + Coolify
Monthly cost~$185~$40 (two servers plus backups)
BillingPer minute of CPU and memoryFlat, per server
DatabasesSeveral on public portsPrivate network only
BackupsPlatform backupsNightly to Cloudflare R2, plus server snapshots
SecretsOn a shared platformNew passwords, on servers I control

The two servers:

  • A small one (4 vCPU, 8 GB) runs only a client's document-processing pipeline. It gets its own machine so nothing I do with my side projects can ever touch it.
  • A bigger one (8 vCPU, 16 GB) runs everything else: Rankioz with its workers, scheduler, Postgres and Redis, RealtyDesk with its WordPress blog, my portfolio, docs and a few small sites.

That is about $1,700 a year saved. Railway was never going to pay me that much.

How the migration went

The move took five days, November 8 to 12. Every site and API moved with zero downtime except the client pipeline, which was down for 14 minutes while its database was copied, in the middle of the client's night. These are the problems worth knowing about before you start.

Coolify ignores your start command on Dockerfile builds

The client pipeline runs five services from one Docker image (API, workers, scheduler), each with its own start command. Coolify ignores the start command when it builds from a Dockerfile and runs the image's default command instead.

The fix is to set the entrypoint per service in Coolify's custom Docker run options. Same image, different --entrypoint for each service.

postgres:// is not postgresql://

Database URLs often start with postgres://. One of my apps uses a library that only accepts postgresql://, and with the wrong one it simply fails to connect. Check the scheme of every database URL before cutover, not during it.

Behind Cloudflare, get the certificate first

My first DNS switch, for rankioz.com, caused about five minutes of Cloudflare 526 errors before I rolled it back. Cloudflare was set to Full (strict) SSL, which means it refuses to talk to an origin without a valid certificate, and the new server did not have one yet.

The fix: install a Cloudflare Origin Certificate in Coolify's proxy first, then switch DNS with the Cloudflare proxy still on. Every switch after that had zero downtime.

Copy the database directly, then count rows

For each database I stopped everything that writes to it, dumped it from Railway straight to the new server over Railway's SSH (pg_dump for Postgres, mysqldump for the WordPress database), restored it, and compared the row count of every table. Rankioz matched on 91 of 91 tables, RealtyDesk on 34 of 34, the client pipeline on 22 of 22. Only then did DNS move.

For the client app, I also pointed the old frontend on Railway at the new API before switching DNS. That way, whichever frontend a user's browser reached during DNS propagation, it was talking to the same database.

Not every free tier holds up

I first tried to serve the static marketing site from Cloudflare Pages for free. The upload left 218 of its 796 files returning server errors, and new projects failed to upload at all. I gave up and served it from Coolify on the same server. It costs nothing extra.

What I would do differently

The breach was Railway's, but the size of the damage was partly mine.

That Gemini key could call any model Google sells, so the attacker went straight for the most expensive ones. Restricted to the one cheap model my product uses, it would have been worthless to them. It had no spending cap either. Any AI key I create now gets both.

What saved me was boring: my app logs every model call it makes. When Google asked for proof that the usage was not mine, I had 7,204 logged calls, all to the same model, none to the ones on the bill.

The slowest part of the whole cleanup was working out where all my keys lived. The migration also turned up things I had stopped seeing. Several databases were reachable from the public internet because that was the platform's easy default. A subdomain still pointed at a Mailgun account I had deleted, which is an open invitation for someone to claim it.

None of that needed a breach to find. It needed someone to look.

If you want a second pair of eyes on your own setup, or help planning a move off Railway, get in touch.

Related Articles

Browse All Articles