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.

Continue Reading

Discover more amazing content handpicked just for you

Code
python

Configuring SQLAlchemy with PostgreSQL on Heroku: A Quick Guide

  • When you provision a PostgreSQL database on Heroku, it sets an environment variable called DATABASE_URL with the connection string for your database.
  • This URI uses the format postgres://.
  • SQLAlchemy (especially when using the psycopg2 driver for PostgreSQL) requires the URI to be in the format postgresql+psycopg2://.
  • This prefix specifies the dialect (postgresql) and the driver (psycopg2) explicitly, which SQLAlchemy uses to establish the connection.

Nov 08, 2024
Read More
Tutorial

How to view tables on a PostgreSQL database hosted on Heroku

After connecting, you can explore the database tables in the client’s interface. Most clients allow you to view tables directly and run SQL queries to list tables with:

   SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';

Nov 06, 2024
Read More
Tutorial

How to view your Heroku Apps

Make sure you’re logged in to the Heroku CLI by running:

   heroku login

Nov 06, 2024
Read More
Article

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

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.

AWS is known for its flexibility and breadth of services but can be complex to configure due to its enterprise-level features. It is perfect for large-scale applications that require advanced features like auto-scaling, load balancing, and security configurations across multiple regions.

Oct 24, 2024
Read More
Cheatsheet

Docker Cheat Sheet

Tag an image with a new name and tag.

docker ps          # Running containers

docker ps -a       # All containers (including stopped)

Aug 01, 2024
Read More
Cheatsheet

Git Cheat Sheet

Delete a local tag.

git push origin --delete tag tag-name

Aug 01, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!