Published on August 01, 2024By DeveloperBreeze

Heroku CLI Cheat Sheet

Getting Started

Login

heroku login

Log in to your Heroku account from the command line.

Logout

heroku logout

Log out from your Heroku account.

App Management

Create an App

heroku create [app-name]

Create a new Heroku app. The app name is optional.

List Apps

heroku apps

List all Heroku apps you have access to.

Rename an App

heroku apps:rename new-name

Rename an existing app.

Delete an App

heroku apps:destroy --app app-name

Permanently delete an app.

Configuration

View Config Vars

heroku config

Display all configuration variables for an app.

Set a Config Var

heroku config:set KEY=value

Set a configuration variable.

Unset a Config Var

heroku config:unset KEY

Remove a configuration variable.

Deploying Code

Deploy with Git

git push heroku main

Push code from your local repository to Heroku (assuming main is your default branch).

Rollback

heroku rollback

Roll back to the previous release.

Releases

heroku releases

List recent releases.

View Logs

heroku logs --tail

Stream logs from your app in real-time.

Add-ons

List Add-ons

heroku addons

List all add-ons for an app.

Add an Add-on

heroku addons:create addon-name

Add an add-on to your app.

Remove an Add-on

heroku addons:destroy addon-name

Remove an add-on from your app.

Dyno Management

Scale Dynos

heroku ps:scale web=1

Scale the number of web dynos to 1.

View Dyno Status

heroku ps

List dynos for an app and their current status.

Restart Dynos

heroku ps:restart

Restart all dynos for an app.

Database Management

List Databases

heroku pg

List all Heroku Postgres databases for an app.

Open PostgreSQL Console

heroku pg:psql

Open an interactive console to the database.

Backup Database

heroku pg:backups:capture

Capture a backup of your database.

Restore Database

heroku pg:backups:restore BACKUP_URL DATABASE

Restore a database from a backup URL.

Collaborators

Add a Collaborator

heroku sharing:add email@example.com

Add a collaborator to your app.

Remove a Collaborator

heroku sharing:remove email@example.com

Remove a collaborator from your app.

Additional Commands

Open App in Browser

heroku open

Open the app in your default web browser.

Run a Command

heroku run command

Run a one-off command in your app environment.

Maintenance Mode

heroku maintenance:on

Enable maintenance mode.

heroku maintenance:off

Disable maintenance mode.

Help

Command Help

heroku help command

Display help for a specific command.

---

This cheat sheet provides a quick reference for the most essential Heroku CLI commands. You can always use heroku help for more detailed information about specific commands or visit the [Heroku CLI documentation](https://devcenter.heroku.com/categories/command-line) for more comprehensive details.

Comments

Please log in to leave a comment.

Continue Reading: