Warning: Bocadillo is now UNMAINTAINED. Users are recommended to migrate to a supported alternative, such as Starlette or FastAPI. Please see #344 for more information.

Heroku deployment

In this guide, we will be looking at how to deploy a Bocadillo application to Heroku. You can find the example code in the heroku-example repo.

Setting things up

Bocadillo application

Let's assume you have the following app.py script:

from bocadillo import App

app = App()

async def index(req, res):
    res.text = "Hello, from Heroku!"


The Procfile is a text file located in the root directory of your project which explicitly declares what command should be executed to start your app.

As described in Deployment, the following should fit most use cases:

web: gunicorn -w 4 -k uvicorn.workers.UvicornWorker app:app


Heroku recognizes a Python app by the existence of requirements.txt file in the root directory (see Python Dependencies via Pip). Here's an example of what yours may look like:



Place this file in the root directory with a specific Python version. Heroku will look at it to determine which Python version to use.


Deploying via the Heroku CLI

  1. Log into the Heroku CLI (you may need to install it on your machine):
heroku login
  1. Create the application on Heroku, e.g.:
heroku create my-bocadillo-app
  1. Add the app's git remote:
heroku git:remote -a my-bocadillo-app
  1. Commit the changes, if any:
git add .
git commit -m “Ready to deploy to Heroku”
  1. Deploy!
git push heroku master

Once this is done, you can visit the newly deployed application using $ heroku open.

Congrats! You've just deployed a Bocadillo application to Heroku. 🚀