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

Instead of manually replacing the URI, you can use libraries like dj-database-url to parse and adapt the DATABASE_URL for different frameworks or drivers. However, the manual approach is straightforward and works well for most cases.

Nov 08, 2024
Read More
Tutorial

How to view tables on a PostgreSQL database hosted on Heroku

   \q

Run the following command to get your database URL:

Nov 06, 2024
Read More
Tutorial

How to view your Heroku Apps

   heroku apps

This will display a list of all the Heroku apps associated with your account.

Nov 06, 2024
Read More
Article

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

In today’s world of cloud computing, selecting the right cloud service provider is a key decision for developers and businesses alike. AWS (Amazon Web Services), DigitalOcean, Heroku, and Vercel are four popular platforms, each offering a distinct set of services and targeting different use cases. While all these platforms revolve around the idea of providing scalable cloud infrastructure, they vary in their approach, complexity, and target audience. In this article, we will break down the core features of each platform to help you make an informed decision based on your project needs.

AWS is one of the most comprehensive cloud computing platforms available. It offers a vast array of services, including compute power (EC2), storage (S3), databases (RDS), machine learning, networking, and much more. AWS provides a range of solutions from Infrastructure-as-a-Service (IaaS) to Platform-as-a-Service (PaaS) and even Software-as-a-Service (SaaS), making it highly suitable for enterprises that need robust and scalable infrastructure.

Oct 24, 2024
Read More

Discussion 0

Please sign in to join the discussion.

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