---
title: "How To Set Up a Staging Environment on Heroku in 3 Easy Steps"
description: "The guide explains how to add a Heroku staging environment so changes are tested in a near-identical, isolated replica before production. It uses a pipeline with production and staging apps, disables production automatic deployments, connects staging to GitHub, and enables automatic builds, with Review Apps offered for pull requests. The setup applies Twelve-Factor practices by separating config vars and databases, recommending migrations into a fresh Postgres database or warning that pg:copy overwrites staging data and can create compliance risks. After validation, slug promotion sends the exact compiled staging asset to production without recompiling, while numbered releases support rollback; database changes must still be reversed separately."
---

# How To Set Up a Staging Environment on Heroku in 3 Easy Steps

[Heroku](https://yomu.fyi/company/heroku) · Andy Smith · Jul 16, 2026

**Type:** Tutorial

## Summary

The guide explains how to add a Heroku staging environment so changes are tested in a near-identical, isolated replica before production. It uses a pipeline with production and staging apps, disables production automatic deployments, connects staging to GitHub, and enables automatic builds, with Review Apps offered for pull requests. The setup applies Twelve-Factor practices by separating config vars and databases, recommending migrations into a fresh Postgres database or warning that pg:copy overwrites staging data and can create compliance risks. After validation, slug promotion sends the exact compiled staging asset to production without recompiling, while numbered releases support rollback; database changes must still be reversed separately.

## Context

The guide addresses the risk of deploying directly from a GitHub-connected production app and explains the need for a near-identical staging environment to catch bugs, environment issues, configuration mismatches, and deployment conflicts before users are affected.

## Approach / What changed

Create a Heroku pipeline containing production and staging apps, connect the staging app to GitHub with automatic deploys, isolate config vars and databases according to Twelve-Factor principles, validate the staging build, and promote its compiled slug to production through the Dashboard or CLI.

## Takeaways

- Heroku pipelines route GitHub changes through staging first, while production automatic deployments are disabled to prevent operational conflicts.
- Staging should use separate config vars and a distinct database; migrations into a fresh Postgres database avoid copying sensitive production data.
- Slug promotion deploys the exact artifact compiled in staging without recompilation, but rolling back a release does not reverse database schema changes or migrations.

**Tags:** [CI/CD](https://yomu.fyi/topic/ci-cd), [Deployment](https://yomu.fyi/topic/deployment), [Heroku](https://yomu.fyi/topic/heroku)

- Source: [Heroku](https://www.heroku.com/blog/how-to-set-up-staging-environment-3-easy-steps)
- Source URL: https://www.heroku.com/blog/how-to-set-up-staging-environment-3-easy-steps
- Ingested by Yomu: 2026-09-10T04:05:34.476Z

[Read original post](https://www.heroku.com/blog/how-to-set-up-staging-environment-3-easy-steps)
