<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/6-lesser-known-heroku-cli-commands-you-probably-aren-t-using-eejglznga" -->

---
title: 6 Lesser-Known Heroku CLI Commands You Probably Aren’t Using
description: A rundown of six underused Heroku CLI commands aimed at cutting browser context-switching: exporting config vars to a local .env file with heroku config -s,...
canonical: https://daily.dev/posts/6-lesser-known-heroku-cli-commands-you-probably-aren-t-using-eejglznga
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: 6 Lesser-Known Heroku CLI Commands You Probably Aren’t Using | daily.dev
og:description: A rundown of six underused Heroku CLI commands aimed at cutting browser context-switching: exporting config vars to a local .env file with heroku config -s,...
og:url: https://daily.dev/posts/6-lesser-known-heroku-cli-commands-you-probably-aren-t-using-eejglznga
og:image: https://api.daily.dev/og/posts/eeJGlznGa.png
og:image:alt: 6 Lesser-Known Heroku CLI Commands You Probably Aren’t Using
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# 6 Lesser-Known Heroku CLI Commands You Probably Aren’t Using

**[Heroku](https://daily.dev/sources/heroku)** · 7 min read · 0 upvotes · 0 comments

## Summary

A rundown of six underused Heroku CLI commands aimed at cutting browser context-switching: exporting config vars to a local .env file with heroku config -s, inspecting live queries with heroku pg:ps, SSH-like live debugging into a dyno with heroku ps:exec, running background tasks safely with heroku run:detached, enabling tab-completion with heroku autocomplete, and jumping straight to an add-on's dashboard with heroku addons:open.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.heroku.com/blog/6-lesser-known-heroku-cli-commands>

## Questions this post answers

### How do I export Heroku config vars directly into a local .env file?

Run heroku config -s -a your-staging-app > .env to print all active config variables as shell key-value pairs and redirect them into a local .env file, overwriting any existing one. To append a single new variable instead of overwriting the whole file, use heroku config:get CONFIG-VAR-NAME -s -a your-staging-app >> .env. This should only be done against staging or sandbox apps, never live production data.

_daily.dev is where developers refining their Heroku and CLI workflows keep up with practical tips like this._

### How can I SSH into a running Heroku dyno to debug a production issue?

Use heroku ps:exec, which establishes a secure SSH tunnel directly into a running dyno without managing SSH keys or opening firewall ports. Running it alone connects to a random web dyno, or add --dyno=web.2 to target a specific instance for isolated debugging, thread dumps, or CPU profiling under real production load.

_Developers troubleshooting live production apps track debugging techniques like this on daily.dev._

### How do I run a long database migration on Heroku without it dying if my connection drops?

Use heroku run:detached instead of heroku run, which spins up a worker container and runs the process fully in the background, decoupled from the local machine. For example, heroku run:detached rake db:migrate returns a container ID like run.1234, and logs can be streamed later with heroku logs --dyno run.1234 --tail.

_daily.dev helps engineers running production database migrations stay current on safer deployment patterns._

---

Tags: [#devops](https://daily.dev/tags/devops), [#productivity](https://daily.dev/tags/productivity), [#postgresql](https://daily.dev/tags/postgresql), [#cli](https://daily.dev/tags/cli), [#heroku](https://daily.dev/tags/heroku)

[View this post on daily.dev](https://daily.dev/posts/6-lesser-known-heroku-cli-commands-you-probably-aren-t-using-eejglznga)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"6 Lesser-Known Heroku CLI Commands You Probably Aren’t Using","url":"https://daily.dev/posts/6-lesser-known-heroku-cli-commands-you-probably-aren-t-using-eejglznga","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/6-lesser-known-heroku-cli-commands-you-probably-aren-t-using-eejglznga"},"datePublished":"2026-08-25T16:39:22.810Z","dateModified":"2026-08-25T16:49:18.380Z","description":"A rundown of six underused Heroku CLI commands aimed at cutting browser context-switching: exporting config vars to a local .env file with heroku config -s,...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/2f6c471c89a0d3dc35c8f49e6e1840bd?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/2f6c471c89a0d3dc35c8f49e6e1840bd?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Heroku","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Heroku","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/5211c8775c204d88836fcbf15d73b1b5","url":"https://daily.dev/sources/heroku"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/6-lesser-known-heroku-cli-commands-you-probably-aren-t-using-eejglznga","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"devops,productivity,postgresql,cli,heroku","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Heroku","item":"https://daily.dev/sources/heroku"},{"@type":"ListItem","position":3,"name":"6 Lesser-Known Heroku CLI Commands You Probably Aren’t Using"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/6-lesser-known-heroku-cli-commands-you-probably-aren-t-using-eejglznga#faq","mainEntity":[{"@type":"Question","name":"How do I export Heroku config vars directly into a local .env file?","acceptedAnswer":{"@type":"Answer","text":"Run heroku config -s -a your-staging-app > .env to print all active config variables as shell key-value pairs and redirect them into a local .env file, overwriting any existing one. To append a single new variable instead of overwriting the whole file, use heroku config:get CONFIG-VAR-NAME -s -a your-staging-app >> .env. This should only be done against staging or sandbox apps, never live production data. daily.dev is where developers refining their Heroku and CLI workflows keep up with practical tips like this."}},{"@type":"Question","name":"How can I SSH into a running Heroku dyno to debug a production issue?","acceptedAnswer":{"@type":"Answer","text":"Use heroku ps:exec, which establishes a secure SSH tunnel directly into a running dyno without managing SSH keys or opening firewall ports. Running it alone connects to a random web dyno, or add --dyno=web.2 to target a specific instance for isolated debugging, thread dumps, or CPU profiling under real production load. Developers troubleshooting live production apps track debugging techniques like this on daily.dev."}},{"@type":"Question","name":"How do I run a long database migration on Heroku without it dying if my connection drops?","acceptedAnswer":{"@type":"Answer","text":"Use heroku run:detached instead of heroku run, which spins up a worker container and runs the process fully in the background, decoupled from the local machine. For example, heroku run:detached rake db:migrate returns a container ID like run.1234, and logs can be streamed later with heroku logs --dyno run.1234 --tail. daily.dev helps engineers running production database migrations stay current on safer deployment patterns."}}]}
```

