- Home
- Frameworks
- Ruby on Rails
Deploy Ruby on Rails without the platform tax
Rails deployment to servers you own
Push to your main branch and Hatchbox builds, migrates, and restarts your Rails app with zero downtime — on servers you own, at raw hosting prices instead of platform markup.
Includes a 7 day free trial. $15 per server per month after that — unlimited apps.
Hatchbox has provided Rails hosting on servers you own since 2016. Point it at a GitHub repository
and a fresh Ubuntu server, and it does the rest — there's no build script to write. It
sees rails in your Gemfile and takes it from there: Ruby versions, bundler,
asset compilation, migrations, the web server, background workers, SSL certificates, and
log streaming.
The Ruby version comes from your .ruby-version, .tool-versions,
or Gemfile.lock. No buildpacks, no Dockerfile, no lock-in — and you keep full
SSH access to a plain, boring server you can debug yourself at 3am.
Why deploy Rails with Hatchbox
Zero-downtime deploys
Each deploy builds into a fresh release directory, then flips the symlink and reloads Puma with a phased restart. Failed builds never take your site down.
Migrations run once
db:migrate runs automatically on the cron server, so it happens exactly
once per deploy no matter how many web servers you're running.
Workers detected for you
Hatchbox spots Solid Queue and Sidekiq on the first deploy and adds the worker process itself. It restarts them on deploy, and again if they crash.
Encrypted credentials just work
Set RAILS_MASTER_KEY as an environment variable and your
credentials.yml.enc decrypts on the server like it does locally.
What customers say
I run 15+ Rails apps and static sites with Hatchbox. My bill went from $400/month on Heroku to $28/mo with Hatchbox & DigitalOcean combined.
Donn Felker
Software Professional
If you want the most bang for your buck, Hatchbox / Hetzner / DigitalOcean is the killer combo. You can throw sooo much at this and it's crazy how inexpensive it is.
Josh Pigford
Serial Entrepreneur
- Applications deployed
- 24,000+
- Deployments run
- 2 million+
- Deploying since
- 2016
How to deploy a Rails app
Four steps from an empty server to a live site. Most people finish in under half an hour.
-
Connect a server
Add a DigitalOcean, Hetzner, AWS, Linode, or Vultr API key and let Hatchbox provision a server, or point it at any existing machine running Ubuntu LTS.
-
Connect your repository
Authorize GitHub and pick the repo and branch. Hatchbox installs a webhook so every push to that branch can deploy automatically.
-
Set your environment variables
Add
RAILS_MASTER_KEY,DATABASE_URL, and anything else your app reads from the environment. -
Deploy
Hit deploy and watch the log stream. Bundle, precompile, migrate, restart — usually a couple of minutes.
What Hatchbox does for you
Hatchbox detects Rails from rails in your Gemfile and configures the deploy
itself. There's no build script to write.
Build steps it runs
- Installs the Ruby version from
.ruby-version,.tool-versions, orGemfile.lock - Installs the matching Bundler version and your gem dependencies
- Runs
assets:precompileif your app has it — skipped automatically for API-only apps - Runs
db:migrateon the cron server, so migrations happen exactly once per deploy
Processes it adds
Created on your first deploy, then kept alive and restarted on every deploy after.
bin/rails server -b 127.0.0.1 -p $PORT # web
bin/jobs # added if Solid Queue is detected
bundle exec sidekiq # added if Sidekiq is detected
Caddy reverse proxies to the web process and load balances across your web servers. Add or scale processes yourself whenever you need to.
Environment variables you set
Added in Hatchbox and written into every release.
RAILS_MASTER_KEY=<contents of config/master.key>
DATABASE_URL=postgres://user:pass@host/db_name
Attach a Postgres or MySQL database in Hatchbox and it sets DATABASE_URL for you. With Solid Cache, Solid Queue or Solid Cable
in your Gemfile.lock, each deploy also creates their databases beside it and sets CACHE_DATABASE_URL, QUEUE_DATABASE_URL and CABLE_DATABASE_URL.
Rails deployment that's safe to run on a Friday
Getting a Rails app online once is the easy part. These are the pieces that make the hundredth deploy as boring as the first.
Deploy on push, from CI, or by hand
With auto deploy on, every push to your branch starts a deploy through the GitHub webhook. Prefer to deploy only after your tests pass? Turn auto deploy off and call your app's deploy webhook URL from the last step of your CI pipeline instead. The Deploy button in the dashboard always works too.
Health checks after every restart
Behind a load balancer, Hatchbox waits after each web server restarts for your app to
answer its health check path before restarting the next, so no two servers are down at
once. If the app doesn't answer within two minutes the deploy is marked as failed
and the remaining servers keep serving the previous release. Rails 7.1+ apps have their
/up route detected on their first deploy; set a health check path in the
app's Caddy settings otherwise. Without one, the deploy waits for the app to answer at
all. Set the HATCHBOX_WAIT_FOR_HEALTH_CHECK
environment variable to wait on a cluster without a load balancer, or to
false to turn the wait off.
# config/routes.rb (Rails 7.1+ ships this route)
get "up" => "rails/health#show", as: :rails_health_check
Hooks for after a deploy, or after a failed one
Commit an executable .hatchbox/post-deploy script to run a task once, on one
server, after each successful deploy. Notify Slack, warm a cache, or kick off a data
backfill. A .hatchbox/failed-deploy script runs when a deploy fails.
#!/usr/bin/env bash
# .hatchbox/post-deploy
set -e
bin/rails runner 'Rails.cache.clear'
One-click rollbacks
Every deploy is kept in your app's history with its commit and full log. If a release misbehaves, hit Rollback on an earlier deploy and Hatchbox redeploys that commit. No shell session or git revert needed.
Rails deployment options compared
There are four common ways to deploy a Rails app. They differ mostly in who sets up the server and who you pay.
| Topic | Hatchbox | Kamal | Capistrano | PaaS (Heroku, Render) |
|---|---|---|---|---|
| Where it runs | Your servers, on any cloud | Your servers, in Docker containers | Your servers | The platform's infrastructure |
| What you write | Nothing to start. Detected from your Gemfile | A Dockerfile and config/deploy.yml | config/deploy.rb and server config | A Procfile or service settings |
| Server setup | Provisioned and hardened for you | You, beyond installing Docker | You: Ruby, web server, database | Handled by the platform |
| Deploys and rollbacks | Push to deploy, dashboard history, one-click rollback | kamal deploy and kamal rollback from your machine | cap deploy and cap deploy:rollback from your machine | Push to deploy, rollbacks in the dashboard |
| What you pay | $15/server/month plus your hosting bill | Free, plus hosting and a container registry | Free, plus hosting and your time | Per dyno or service, database, and add-on |
Going deeper on one of them? Read Hatchbox vs Kamal, Hatchbox vs Heroku, or Hatchbox vs Render.
Rails deployment questions
Still stuck? Ask us directly — a real person who has deployed a lot of Rails apps will answer.
Can I run multiple Rails apps on one server?
Does Hatchbox support Solid Queue, Solid Cache, and Solid Cable?
bin/jobs process for Solid Queue on the first deploy, and when your app has a Postgres or MySQL database attached, the deploy creates a database for each Solid gem beside it and sets CACHE_DATABASE_URL, QUEUE_DATABASE_URL and CABLE_DATABASE_URL, the names the Rails 8 defaults read.
What about Active Storage and file uploads?
Can I still SSH into the server?
rails console, tail logs, inspect processes — it's your server.
How do I roll back a bad Rails deploy?
Simple, predictable pricing.
We charge per server, not per app. Run one application or twenty on the same box — the bill doesn't change.
$15
- Unlimited applications
- Deploy anywhere
- Zero downtime deployments
- Custom domains & free SSL
- Databases, cron jobs & background workers
- Full SSH access to your servers
- Real, human support
- 7 day free trial
Deploy more than Rails
One server, one bill, as many apps as it can hold. Run any of these alongside your Rails app for no extra cost.
- Ruby Deploy Hanami Hanami hosting on infrastructure you control
- Ruby Deploy Bridgetown Bridgetown hosting with full server access
- Go Deploy Hugo Hugo hosting without the per-site pricing
- Ruby Deploy Jekyll Jekyll hosting with real server access
- Ruby Deploy Middleman Middleman hosting on your own infrastructure
- JavaScript Deploy Astro Astro hosting with no vendor lock-in
Ready to deploy your Rails app?
Hatchbox has run more than 2 million deploys across 24,000+ applications since 2016. Start a 7 day free trial and put yours on a server you own.