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 for more comprehensive details.

Related Posts

More content you might like

Code
python

Configuring SQLAlchemy with PostgreSQL on Heroku: A Quick Guide

Heroku's DATABASE_URL uses the older postgres:// scheme, which isn't compatible with the latest SQLAlchemy requirements. Starting with SQLAlchemy 1.4, postgres:// is considered deprecated and no longer supported. The explicit postgresql+psycopg2:// scheme is required.

Without this replacement, SQLAlchemy might throw an error like:

Nov 08, 2024
Read More
Tutorial

How to view tables on a PostgreSQL database hosted on Heroku

Replace <your-app-name> with the name of your Heroku application.

Once connected to the database, you can list all tables with:

Nov 06, 2024
Read More
Tutorial

How to view your Heroku Apps

No preview available for this content.

Nov 06, 2024
Read More
Article

Comparing AWS, DigitalOcean, Heroku, and Vercel: Understanding Cloud Service Providers and Their Offerings

Heroku is a platform-as-a-service (PaaS) provider that simplifies application deployment by abstracting away the complexity of managing servers. Its key strength is in enabling developers to focus on building applications without needing to handle infrastructure concerns such as server configuration or scaling. Heroku is especially useful for web applications that are written in languages like Ruby, Node.js, Python, and PHP.

Heroku is well-known for its ease of use, automatic scaling, and straightforward deployment process. However, this simplicity comes at a higher cost compared to IaaS services like DigitalOcean, making it best suited for developers who want to streamline application deployment rather than deal with detailed infrastructure management.

Oct 24, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!