# How to Deploy a Ruby on Rails App on Heroku in 2026

> Learn to deploy Ruby on Rails on Heroku in 2026. Covers Postgres setup, Procfile, rake db:migrate, common errors, real costs, and a faster alternative.
- **Author**: shreya-menon
- **Published**: 2026-05-06
- **Modified**: 2026-05-06
- **Category**: Deployment Guides
- **URL**: https://kuberns.com/blogs/how-to-deploy-ruby-on-rails-on-heroku/

---

Deploying a Ruby on Rails app on Heroku takes about 15 to 30 minutes if your stack is set up correctly. The process involves switching your database from SQLite to PostgreSQL, creating a Procfile, configuring Puma, and pushing your code via Git. This guide covers every step, including the errors that break most deployments, and what the real cost looks like once your app is live.

## What You Need Before Deploying Rails on Heroku

Before you run a single Heroku command, make sure your local project is ready. Missing any of these is the most common reason Rails deployments fail on the first push.

**PostgreSQL instead of SQLite** - Heroku's dyno file system resets on every restart. Any SQLite data stored on disk is permanently lost. You must use PostgreSQL.

**Ruby 3.2+ and Rails 7 or Rails 8** - Pin the exact Ruby version in your Gemfile (`ruby '3.2.2'`) so Heroku builds against the same version you developed on.

**Heroku CLI installed and authenticated** - Download from the Heroku Dev Center and run `heroku login` to authenticate.

**The `pg` gem in your Gemfile** - Replace `sqlite3` with `pg`. Heroku will reject a build that still references SQLite in the Gemfile.

**A Procfile at your project root** - Heroku reads this file to know how to start your app. Without it, no web dyno will start.

> **"Still deciding which platform to host your Rails app on?"**
> Read: [Top Heroku Alternatives in 2026 Compared](https://kuberns.com/blogs/the-ultimate-guide-to-heroku-alternatives-in-2025/)

## How to Deploy a Ruby on Rails App on Heroku: Step by Step

### Step 1: Switch from SQLite to PostgreSQL

Open your Gemfile and replace:

```ruby
gem 'sqlite3'
```

With:

```ruby
gem 'pg', '~> 1.5'
```

Then update `config/database.yml` to use the PostgreSQL adapter in all environments:

```yaml
default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: myapp_development

test:
  <<: *default
  database: myapp_test

production:
  <<: *default
  url: <%= ENV['DATABASE_URL'] %>
```

Run `bundle install` to update your lockfile. If you are on macOS and get a pg build error, install the PostgreSQL client with `brew install libpq`.

### Step 2: Configure Puma and Create Your Procfile

Rails ships with Puma as the default web server. Create or update `config/puma.rb`:

```ruby
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count

port ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "development" }

workers ENV.fetch("WEB_CONCURRENCY") { 2 }
preload_app!

on_worker_boot do
  ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
end

plugin :tmp_restart
```

Now create a `Procfile` at the root of your project (no file extension):

```
web: bundle exec puma -C config/puma.rb
release: bin/rails db:migrate
```

The `release:` line tells Heroku to run your database migrations automatically on every deploy, before the new version goes live. This prevents the app from crashing on a stale schema.

### Step 3: Set Your Rails Secret Key Base

Rails 7 and 8 use encrypted credentials. Heroku needs access to your master key to decrypt them.

```bash
heroku config:set RAILS_MASTER_KEY=$(cat config/master.key)
```

Never commit `config/master.key` to Git. If you are using `SECRET_KEY_BASE` directly instead of encrypted credentials, set it the same way:

```bash
heroku config:set SECRET_KEY_BASE=$(rails secret)
```

### Step 4: Create the Heroku App and Push

Make sure your project is a Git repository with at least one commit:

```bash
git init
git add .
git commit -m "Initial commit"
```

Create the Heroku app and push:

```bash
heroku create your-app-name
git push heroku main
```

Watch the build log carefully. Heroku auto-detects your Ruby version, runs `bundle install`, and runs `bin/rails assets:precompile`. A successful build ends with a deployed URL like `https://your-app-name.herokuapp.com`.

**Rails 8 note:** Rails 8 ships with Propshaft instead of Sprockets for the asset pipeline. If you are deploying a Rails 8 app and using esbuild or importmaps, confirm that your `Gemfile` does not still reference `sprockets-rails` unless you intentionally kept it. Heroku's official documentation still covers Rails 7, so you may need to refer to the Rails 8 changelog for buildpack-specific changes.

### Step 5: Add Heroku Postgres and Run Migrations

Provision a Postgres database:

```bash
heroku addons:create heroku-postgresql:essential-0
```

Heroku sets the `DATABASE_URL` environment variable automatically. Your `config/database.yml` production block (using `url: <%= ENV['DATABASE_URL'] %>`) will pick it up without any changes.

If you added the `release:` task to your Procfile, migrations already ran during the deploy. To verify, or to run them manually:

```bash
heroku run rake db:migrate
```

### Step 6: Handle Assets and Static Files

Heroku runs `bundle exec rails assets:precompile` automatically during the build if you have Sprockets or Propshaft configured. If asset compilation fails, it is almost always one of two causes:

**Missing Node.js buildpack** - If your app uses esbuild, webpack, or Tailwind, you need the Node.js buildpack added before the Ruby one:

```bash
heroku buildpacks:clear
heroku buildpacks:add heroku/nodejs
heroku buildpacks:add heroku/ruby
```

**Static files not served** - Set the env var to allow Rails to serve assets directly from Heroku:

```bash
heroku config:set RAILS_SERVE_STATIC_FILES=true
```

### Step 7: Set Remaining Environment Variables

Set any other app-specific environment variables before you share the URL:

```bash
heroku config:set RAILS_ENV=production
heroku config:set WEB_CONCURRENCY=2
heroku config:set RAILS_LOG_TO_STDOUT=true
```

Verify everything is set correctly:

```bash
heroku config
```

Open your app to confirm it is running:

```bash
heroku open
```

> **"Running a Postgres database on Heroku? The pricing tiers are not obvious."**
> Read: [Heroku Postgres: Plans, Pricing, Setup, and Alternatives in 2026](https://kuberns.com/blogs/heroku-postgres/)

## Common Heroku Rails Deployment Errors and How to Fix Them

![Common Heroku Rails deployment errors and fixes](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/heroku-errors.png)

Most Rails deployments on Heroku fail for the same handful of reasons. Here is what each error means and how to resolve it.

### H10: App Crashed

This is the most common error and almost always means one of three things: your Procfile is missing, the `web:` process command is wrong, or the app crashed immediately on boot.

Check your Procfile exists at the project root (not inside a subdirectory) and contains exactly:

```
web: bundle exec puma -C config/puma.rb
```

Then check your logs for the real cause:

```bash
heroku logs --tail
```

Scale the web dyno explicitly if it dropped to zero:

```bash
heroku ps:scale web=1
```

### rake db:migrate Fails on Release

If the `release:` task fails, your deploy is rolled back automatically. The two most common causes are:

- `DATABASE_URL` not set  -  run `heroku config` and confirm the variable exists. If missing, re-attach the Postgres add-on with `heroku addons:attach <addon-name>`.
- Pending migration references a column that does not exist on the existing schema  -  you need to fix the migration order or run a manual migration with `heroku run rake db:migrate` after pushing the corrected code.

### Asset Precompilation Failure

If the build log shows `ExecJS::RuntimeError` or `Yarn not found`, your app uses JavaScript bundling but the Node.js buildpack is not configured.

```bash
heroku buildpacks:add --index 1 heroku/nodejs
git commit --allow-empty -m "add nodejs buildpack"
git push heroku main
```

### No Web Processes Running

This happens when your dyno count drops to zero, which can occur after plan changes or if Heroku automatically suspends an inactive app on older plans.

```bash
heroku ps:scale web=1
```

If the app still does not start, check whether your account has an active plan with enough dyno hours.

### R14: Memory Quota Exceeded

An Eco or Basic dyno has 512MB of RAM. A typical Rails app with active gems can consume 300-500MB at startup alone. When you hit R14, the dyno starts swapping to disk, which causes severe slowdowns before the process is eventually killed.

Short term: upgrade to a Standard-2X dyno (1GB RAM). Long term: profile your app with `derailed_benchmarks` or `rack-mini-profiler` to find which gems or queries are consuming memory.

> **"Getting these errors in production? The real problem may be GitHub auto-deploy breaking silently."**
> Read: [Why Heroku GitHub Integration Breaks and What to Use Instead](https://kuberns.com/blogs/heroku-github-integration/)

## What Does Heroku Actually Cost for a Rails App in 2026?

![Heroku pricing for Rails apps in 2026](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/heroku-pricing-for-rails.png)

Heroku no longer has a free tier. Every running app costs real money, and the billing model is per component  -  you pay separately for dynos, databases, Redis, and any add-ons.

Here is what a typical Rails deployment looks like at different stages:

| Setup | Monthly Cost | Best For |
|---|---|---|
| Eco dyno + Postgres Essential-0 | ~$10/mo | Side projects, prototypes |
| Basic dyno + Postgres Essential-1 | ~$20/mo | Early-stage apps |
| Standard-1X + Postgres Mini | ~$55/mo | Production, low traffic |
| Standard-2X + Postgres Standard-0 | ~$155/mo | Production, medium traffic |
| 2x Standard-2X + Postgres Standard-2 | ~$400+/mo | Scaling apps |

The number that surprises most founders: a Rails SaaS serving 12,000 users on two Standard-2X dynos with a Postgres Standard-0 database and Redis Premium-0 can reach **$1,400/month** without any traffic spikes or add-on overages. The per-component billing model means every layer you add multiplies the cost.

> **"The bill always comes later than the pain. See the full Heroku pricing breakdown."**
> Read: [Heroku Pricing Breakdown and Ways to Reduce Costs](https://kuberns.com/blogs/heroku-pricing-explained/)

## The Fastest Way to Deploy a Rails App in 2026: Use Kuberns

![Deploy Rails app on Kuberns - Agentic AI platform](https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/kuberns-home-page-new.png)

Once you have seen what Heroku costs at scale, it is worth knowing the alternative before you commit to the stack.

[Kuberns](https://kuberns.com) is an Agentic AI cloud platform built on AWS. Connect your GitHub repo and Kuberns reads your Rails project automatically. It detects your Ruby version, framework, dependencies, and database requirements without any configuration files. No Procfile. No buildpack selection. No CLI setup.

**Here is what makes Kuberns different from every other PaaS:**

**Agentic AI deployment** - Kuberns does not just automate deployment. The AI understands your stack, detects your framework, chooses the right runtime, configures your build steps, and manages the full deployment lifecycle from push to live URL. You never touch a config file.

**Zero cold starts** - Unlike Heroku's Eco and Basic dynos that sleep after inactivity, Kuberns keeps your app warm and responsive at all times. No users hitting a slow first load.

**No per-component billing** - Heroku charges separately for dynos, Postgres, Redis, and every add-on. Kuberns bundles compute, managed database, HTTPS, autoscaling, and monitoring into one flat rate. No surprise line items at end of month.

**Automatic CI/CD from GitHub** - Every push to your main branch triggers a full build and deploy pipeline. No webhook setup, no GitHub Actions YAML, no manual configuration.

**Up to 40% lower cost vs direct AWS** - Because Kuberns manages infrastructure at scale, you get AWS-grade uptime at a fraction of what self-managed AWS costs.

**Deploy your Rails app in 3 steps:**

1. Connect your GitHub repository to Kuberns
2. Set your environment variables in the dashboard
3. Click Deploy - your app is live with HTTPS and CI/CD in under 5 minutes

Every push to your main branch triggers an automatic redeploy. Postgres is provisioned as part of your app, not as a separate billable add-on.

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/deploy-on-kuberns-bannner6.png" alt="Deploy your Rails app on Kuberns" style={{ width: "100%", height: "auto" }} />
</a>

## Heroku vs Kuberns for Rails in 2026

| | Heroku | Kuberns |
|---|---|---|
| Setup time | 15 to 30 minutes | Under 5 minutes |
| Procfile required | Yes | No |
| PostgreSQL setup | Manual add-on | Included |
| CI/CD from GitHub | Manual configuration | Automatic |
| Cold starts | Yes (Eco and Basic plans) | No |
| Rails 8 support | Partial (docs still on Rails 7) | Auto-detected |
| Asset pipeline config | Manual buildpack order | Auto-detected |
| Billing model | Per component (dynos + DB + add-ons) | Flat rate, all included |
| Entry price | ~$10/month | ~$7/month |
| At scale (12k users) | $400 to $1,400/month | Up to 40% less |

> **"Still evaluating Heroku vs the full field of modern PaaS platforms?"**
> Read: [Best Heroku Alternatives in 2026](https://kuberns.com/blogs/the-ultimate-guide-to-heroku-alternatives-in-2025/)

## Conclusion

Deploying a Ruby on Rails app on Heroku is a well-documented process  -  switch to PostgreSQL, write a Procfile, configure Puma, push via Git. It works, and for a side project or prototype it is a reasonable starting point at around $10/month.

The friction shows up as your app grows. The per-component billing model, manual Postgres provisioning, required Procfile and buildpack configuration, and cold starts on lower dyno tiers all add overhead that compounds over time. A production Rails app serving real traffic can cost $400-$1,400/month on Heroku without doing anything unusual.

If you want Heroku-style simplicity with none of the configuration overhead, [Kuberns](https://kuberns.com) auto-detects your Rails stack, provisions Postgres, and gives you CI/CD from GitHub without a single config file. The Agentic AI handles the full deployment lifecycle so your team can stay focused on building.

[Start deploying your Rails app on Kuberns for free](https://dashboard.kuberns.com)

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs-media.s3.ap-south-1.amazonaws.com/CTA_banner.png" alt="Try Kuberns free - Deploy Rails in minutes" style={{ width: '100%', height: 'auto', cursor: 'pointer' }} />
</a>

## Frequently Asked Questions

### Q: Does Heroku support Rails 8?

Yes, Heroku supports Rails 8, but its official documentation still focuses on Rails 7. Rails 8 ships with Propshaft instead of Sprockets and uses Kamal for containerized deployment by default. You can still deploy Rails 8 to Heroku using the standard `git push` workflow, but you may need to adjust your asset pipeline and buildpack configuration manually.

### Q: Do I need a Procfile to deploy Rails on Heroku?

Yes. Heroku requires a Procfile at the root of your project to know how to start your app. The minimum entry is `web: bundle exec puma -C config/puma.rb`. Without it, Heroku cannot start a web dyno and your deployment will fail with a "no web processes running" error.

### Q: How do I run rake db:migrate on Heroku?

You can run migrations two ways. The recommended approach is to add a release phase to your Procfile: `release: bin/rails db:migrate`. This runs automatically on every deploy. Alternatively, run it manually after each push using `heroku run rake db:migrate` from your terminal.

### Q: Why does Heroku require PostgreSQL instead of SQLite for Rails?

Heroku's dyno file system is ephemeral, meaning it resets on every restart or redeploy. SQLite stores data as a file on disk, so any data written to it is permanently lost when the dyno restarts. PostgreSQL is a managed database service that stores data independently of the dyno, making it the only reliable database option on Heroku.

### Q: How much does it cost to host a Rails app on Heroku in 2026?

The minimum is around $10/month for an Eco dyno plus a Postgres Essential-0 plan. For production apps with real traffic, expect $55-$155/month. A Rails SaaS serving 12,000 users on standard dynos can reach $1,400/month depending on dyno size, Postgres tier, and add-ons.

### Q: What is the fastest Heroku alternative for Rails in 2026?

[Kuberns](https://kuberns.com) is an Agentic AI cloud platform that auto-detects your Rails stack, provisions a managed Postgres database, and deploys your app with HTTPS and CI/CD in under 5 minutes. No Procfile, no buildpack config, no CLI setup required. It costs up to 40% less than equivalent Heroku plans.

### Q: Can I deploy a Rails app for free in 2026?

Heroku removed its free tier in November 2022. Kuberns offers free credits worth approximately $14 for 30 days, which is enough to run a small Rails app with a managed database included. Render and Railway also have free tiers with limitations on uptime and memory.

### Q: How do I add Redis to a Rails app on Heroku?

Run `heroku addons:create heroku-data-for-redis:mini` to provision a Redis instance. Heroku sets a `REDIS_URL` environment variable automatically. In your Rails app, configure Action Cable, Sidekiq, or your caching layer to read from `ENV['REDIS_URL']`. Redis on Heroku starts at $3/month for the mini plan.

---
- [More Deployment Guides articles](https://kuberns.com/blogs/category/deployment-guides/1/)
- [All articles](https://kuberns.com/blogs/)