Heroku Tutorial
Learn Heroku step by step: 37 lessons in 9 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- What Is Heroku? Learn what Heroku is, what a platform as a service does for you, how it differs from servers and containers, and what you can and cannot practice on this site.
- How the Heroku Platform Works Follow a request through the Heroku router to your dynos, see how code becomes a slug, and learn the twelve-factor habits that make an app fit the platform.
- Install the Heroku CLI and Log In Create a Heroku account, install the Heroku CLI on Windows, macOS or Linux, log in safely, and learn how the CLI decides which app a command targets.
- Deploy Your First App Deploy a small Node.js web app to Heroku step by step: prepare the code, create the app, push with Git, open it, read the logs and fix the common first-deploy errors.
- CLI Essentials and Reading Logs Learn the Heroku CLI commands you will use every day, how Heroku's log stream is formatted, how to filter it, and how to read router lines to debug slow or failing requests.
Apps, Dynos and Buildpacks
- Dynos and Dyno Types Understand Heroku dynos: what they are, process types, the Eco, Basic, Standard and Performance families, sleeping, memory limits and how dyno hours are counted.
- Procfile and Process Types Learn the Heroku Procfile format, the special web and release process types, how to add worker and clock processes, and how to scale each type independently.
- Buildpacks Learn how Heroku buildpacks turn source code into a slug: the detect, compile and release steps, setting and ordering multiple buildpacks, and writing custom ones.
- Stacks and Runtime Versions Understand Heroku stacks (the operating system image) and language runtime versions, how to pin Node.js, Python, Ruby and Java versions, and how to change stacks safely.
- Dyno Lifecycle and the Ephemeral Filesystem Learn how dynos start, restart and stop, why Heroku's filesystem is ephemeral, how to handle SIGTERM gracefully, and where to keep data that must survive.
Deployment and Releases
- Git Deploys and Slugs Deploy to Heroku with git push, deploy a feature branch or subfolder, use GitHub integration, control slug contents with .slugignore and stay under the slug size limit.
- Releases and Rollbacks Understand Heroku releases: what creates one, how to list and inspect them, how rollback really works, what it cannot undo, and how to deploy with a safety net.
- Release Phase and Database Migrations Use the Heroku release phase to run database migrations and other tasks before new code goes live, understand what happens when it fails, and make migrations safe to rerun.
- Container Deploys with Docker Deploy Docker images to Heroku two ways: build from a Dockerfile with heroku.yml, or push a prebuilt image with the container registry, and avoid the common PORT and CMD mistakes.
Add-ons and Config
- Config Vars Manage Heroku config vars: set, read and remove them with the CLI, read them safely in your code, parse DATABASE_URL, and avoid leaking secrets into Git, logs or dashboards.
- Heroku Local and .env Files Run your Procfile processes on your own computer with heroku local, load settings from a .env file, keep secrets out of Git, and mirror production behavior while developing.
- Add-ons Overview Learn how Heroku add-ons work: provisioning with addons:create, plans, attachments and config vars, sharing between apps, popular add-ons and how to control cost.
- app.json: The App Manifest Describe a whole Heroku app in code with app.json: environment variables, add-ons, buildpacks, formation and scripts, and see how review apps and Heroku Buttons use it.
Postgres and Data
- Heroku Postgres Essentials Provision Heroku Postgres, understand the plan tiers, connect with heroku pg:psql, inspect the database with pg:info and read the DATABASE_URL that Heroku sets for you.
- Connections and DATABASE_URL in Code Use DATABASE_URL correctly in your code, avoid the postgres:// versus postgresql:// trap, count connections across dynos and learn when to add a pooler.
- Heroku Postgres Backups and Restore Capture, schedule, download and restore Heroku Postgres backups, copy data between apps with pg:copy, and learn how retention and recovery objectives guide your plan.
- Followers, Rollback and Upgrades Understand Heroku Postgres followers, forks, rollback and failover, how to read replication lag, and how a major PostgreSQL version upgrade is planned and carried out.
Scaling and Performance
- Scaling Dynos Horizontally and Vertically Learn how to scale a Heroku app with heroku ps:scale and ps:type, the difference between more dynos and bigger dynos, and how to size capacity with simple math.
- Dyno Types, Autoscaling and Cost Compare Eco, Basic, Standard and Performance dynos, learn how Heroku autoscaling works for Performance dynos, and estimate monthly dyno cost with a simple model.
- Caching with the Key-Value Store Use Heroku's managed Redis-compatible Key-Value Store for caching and queues: provisioning, REDIS_URL, eviction policy, TTLs, cache-aside and common mistakes.
- Router Metrics and Request Timeouts Read Heroku router log lines, understand connect and service time, the 30 second request timeout (H12), memory errors R14 and R15, and what the Metrics tab shows.
CI, Pipelines and Review Apps
- Pipelines and Promotion Group Heroku apps into a pipeline with review, development, staging and production stages, connect GitHub, auto-deploy branches and promote the same slug between stages.
- Heroku CI: Test Runs Run your test suite on Heroku CI: enable it for a pipeline, configure the test environment in app.json, add Postgres and Redis for tests, and read results from the CLI.
- Review Apps and app.json Create a disposable Heroku app for every pull request with review apps: app.json structure, env defaults, add-ons, the postdeploy script, seed data and automatic cleanup.
Operations and Alternatives
- Logging, Drains and Log Parsing Understand Heroku's Logplex stream, read logs with heroku logs, send them to a log drain, write structured logfmt lines and count errors with a small parser.
- Security, Teams and Access Secure a Heroku app: team roles and collaborators, two-factor authentication, handling secrets in config vars, token hygiene, Private Spaces and Shield, and a security audit stand-in.
- Custom Domains and TLS Point your own domain at a Heroku app: heroku domains:add, DNS target, CNAME versus ALIAS for apex domains, automated certificate management, redirects and HSTS.
- Troubleshooting Heroku Errors A practical method for debugging a broken Heroku app: read logs, check dyno state, decode H and R error codes, roll back a release, use maintenance mode and run one-off dynos.
- Heroku Alternatives and Migration Compare Heroku with other ways to host an app: PaaS rivals, container platforms, serverless, frontend hosts and self-hosting, and plan a portable app and a safe migration.
Projects and Practice
- Project: Flask API with Postgres Build and deploy a small Flask notes API on Heroku with gunicorn, a Procfile, Postgres via DATABASE_URL, a release-phase migration and a smoke test. Runs locally with SQLite stand-ins.
- Project: Node App with a Pipeline Ship a small Node.js app through a full Heroku pipeline: package.json engines and start script, app.json for CI and review apps, staging, promotion and a graceful shutdown.
- Practice: Production Readiness Checklist Review a Heroku app before launch: dynos, database, config, security, logging, backups, deploys and runbooks, then work through practice exercises with runnable calculators.