Skip Navigation
Show nav
Heroku Dev Center Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
Heroku Dev Center Dev Center
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log in or Sign up
View categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
    • Buildpacks
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Node.js Behavior in Heroku
      • Working with Node.js
      • Troubleshooting Node.js Apps
    • Ruby
      • Rails Support
        • Working with Rails
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
    • Heroku Inference
      • Heroku Inference Quick Start Guides
      • Inference API
      • Inference Essentials
      • AI Models
    • Tool Use
    • Vector Database
    • AI Integrations
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
    • Heroku AppLink
      • Heroku AppLink Reference
      • Getting Started with Heroku AppLink
      • Working with Heroku AppLink
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Other Salesforce Integrations
  • Language Support
  • Ruby
  • Working with Ruby
  • Deploying Rack-based Apps

Deploying Rack-based Apps

English — 日本語に切り替える

Last updated October 09, 2025

Table of Contents [expand]

  • Create a Rack app
  • Deploy a Rack app to Heroku
  • Configure web process
  • Frameworks
  • Database access
  • Rack::Sendfile

Heroku supports Rack and Rack-based web frameworks like Sinatra, Ramaze, and Camping.

To run a Rack-based app, include a Gemfile, as well as a rackup file named config.ru in the app’s root directory. The config.ru file convention has become common, so most existing Rack applications should not require changes to deploy to Heroku.

Create a Rack app

First, create a new directory and write a simple config.ru file:

$ mkdir hello
$ cd hello

Create a config.ru file with the following contents:

# config.ru
run lambda { |env| [200, {'Content-Type'=>'text/plain'}, StringIO.new("Hello World!\n")] }

Create a Gemfile to declare you dependencies:

source "https://rubygems.org"

gem "rack"
gem "rackup"
gem "puma"

Install dependencies:

$ bundle install

Boot the server

$ bundle exec rackup -p 9292 config.ru

Test with curl or by visiting http://localhost:9292 in the browser:

$ curl http://localhost:9292
Hello World!

Deploy a Rack app to Heroku

Add the contents to git:

$ git init
$ git add .
$ git commit -m 'pure rack app'

Create a new heroku application and push to it:

$ heroku create
$ git push heroku main

The app is now deployed to Heroku. Test by executing heroku open or by visiting your app’s URL in your browser. You should see Hello, World!.

Configure web process

The Ruby officially supported buildpack automatically configured the command to boot your Rack app. If you want to configure it, you can do so by creating a file named Procfile at the root of your project with a web key:

# Procfile
web: bundle exec puma -C config/puma.rb

You can learn more about Procfile here.

Frameworks

Any framework that uses Rack is supported on Heroku, including (but not limited to) Ruby on Rails, Sinatra, and Hanami.

Database access

Using ActiveRecord

For non-Rails apps using ActiveRecord standalone, put this code into your application to access the DATABASE_URL:

require 'active_record'

ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'] || 'postgres://localhost/mydb')

The code above uses a default local PostgreSQL database named mydb, but you can change this value to point anywhere you like, or override it by running your app with the DATABASE_URL environment variable set in your shell.

Using DataMapper or Sequel

DataMapper and Sequel both use database URLs natively, so configuration is a snap:

For DataMapper:

require 'data_mapper'

DataMapper.setup(:default, ENV['DATABASE_URL'] || 'postgres://localhost/mydb')

For Sequel:

require 'sequel'

Sequel.connect(ENV['DATABASE_URL'] || 'postgres://localhost/mydb')

Rack::Sendfile

Rack::Sendfile is typically used to serve static files directly from a web server instead of through your Ruby application.

Heroku does not support the use of Rack::Sendfile. Rack::Sendfile usually requires that a front-end web server like Nginx or Apache be running on the same machine as your app. This is not how Heroku is architected. Using theRack::Sendfilemiddleware **will cause your file downloads to fail because it sends a body with aContent-Length` of 0.

By default, Rails sets this to nil, but make sure that config.action_dispatch.x_sendfile_header is not set in config/enviroments/production.rb.

If you want to serve files from your Rack application, you can use Rack::Static to have Ruby serve them directly:

# config.ru
require "rack/static"

use Rack::Static, urls: ["/images", "/js", "/css"], root: "public"

Keep reading

  • Working with Ruby

Feedback

Log in to submit feedback.

Using WebSockets on Heroku with Ruby Running Rake Commands

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices