Heroku is a web hosting platform supporting many languages. This guide is a reference to the Heroku CLI.

Apps

login - Log in

heroku login
heroku auth:whoami      # show the logged-in user

create - Create an app

heroku create sushi
git push heroku main

Creates an app and adds a heroku git remote. Push a branch to deploy. (docs)

heroku git:remote -a sushi

Adds the heroku remote to a repo that wasn't created by heroku create.

apps - Applications

heroku apps                  # list
heroku apps:info
heroku open                  # open in browser
heroku apps:rename NEWNAME
heroku apps:destroy -a APP --confirm APP

access - Collaboration

Manage collaborators

heroku access                     # list
heroku access:add me@xy.com
heroku access:remove me@xy.com

Transfer to another owner

heroku apps:transfer new@owner.com

Deploy

container - Docker containers

heroku create sushi --stack container
heroku container:login
heroku container:push web -a sushi
heroku container:release web -a sushi

Containers deploy via the Heroku Container Registry. (docs)

releases - Releases and rollbacks

heroku releases
heroku releases:info v25
heroku releases:rollback v24   # roll back to v24

Processes

ps - Managing processes

heroku ps                        # list dynos
heroku ps:scale web=1            # scale a process type
heroku ps:scale web=2:Standard-2X
heroku ps:restart                # restart all dynos
heroku ps:exec                   # SSH into a dyno

run - Running tasks

heroku run bash
heroku run rails console
heroku run rake assets:precompile

logs - Show logs

heroku logs
heroku logs -t        # --tail (stream)
heroku logs -s app    # --source (app logs only)
heroku logs -p web    # --process-type

maintenance - Maintenance mode

heroku maintenance:on
heroku maintenance:off

Database

pg - PostgreSQL

Create a database

heroku addons:create heroku-postgresql:essential-0
heroku pg:info

addons:create takes a SERVICE:PLAN argument; addons:add still works as a hidden alias.

Backups

heroku pg:backups:capture
heroku pg:backups:schedule DATABASE_URL --at '02:00 UTC'
heroku pg:backups

Manual and scheduled backups are built into Heroku Postgres. (docs)

Configuration

config - Environment variables

heroku config        # list
heroku config -s     # shell format
heroku config:get KEY
heroku config:set KEY=val
heroku config:set KEY1=val KEY2=val
heroku config:unset KEY1

domains - Custom domains

heroku domains:add example.com
heroku domains:add www.example.com
heroku domains:remove example.com
heroku domains:clear

Wildcard domains

heroku domains:add '*.example.com'

Wildcard domains are supported natively; no add-on is needed. (docs)

Local development

local - Run locally

heroku local              # run the Procfile
heroku local web          # one process type
heroku local:run bin/migrate

heroku local reads config vars from .env (change with -e).

References

0 Comments for this cheatsheet. Write yours!