Production
This guide covers the fastest safe path to getting AI SaaS Template into production on Heroku. The goal is to establish a clean deployment baseline first, then connect the services that make the app launch-ready: database, cache, storage, email, billing, and your domain.
Before You Deploy
Make sure you already have:
- a project that runs locally
- a Heroku account
- the Heroku CLI installed
- a Git remote for your project
- an AWS S3 bucket if you chose AWS-backed static and media storage
1. Create the Heroku app
Log in and create the app:
heroku login
heroku create interviewdb
Heroku will assign a temporary hostname such as interviewdb-abc123456efg.herokuapp.com. Keep that value nearby because you will use it in DJANGO_ALLOWED_HOSTS until your custom domain is live.
2. Provision PostgreSQL and Redis
Create the required add-ons:
heroku addons:create heroku-postgresql:essential-0
heroku addons:create heroku-redis:mini
Heroku automatically injects DATABASE_URL and REDIS_URL after those add-ons are provisioned.
Heroku retired the old free and mini PostgreSQL plans. Use an essential-*
plan for new projects.
If you want managed backups, schedule them as well:
heroku pg:backups schedule --at '02:00 US/Pacific' DATABASE_URL
3. Set the required config vars
Run the following commands and replace the placeholder values with your real project values:
heroku config:set WEB_CONCURRENCY=3
heroku config:set DJANGO_DEBUG=False
heroku config:set PYTHONHASHSEED=random
heroku config:set DJANGO_SETTINGS_MODULE=config.settings.production
heroku config:set DJANGO_SECRET_KEY="$(openssl rand -base64 64)"
heroku config:set DJANGO_ADMIN_URL="john_wick/"
heroku config:set DJANGO_ALLOWED_HOSTS="interviewdb-abc123456efg.herokuapp.com,interviewdb.com,www.interviewdb.com"
What these settings do:
DJANGO_SETTINGS_MODULEensures the Heroku release phase and web dynos use production settings.DJANGO_SECRET_KEYgives Django a strong production-only signing key.DJANGO_ADMIN_URLmoves the admin off the default/admin/path. Include the trailing slash.DJANGO_ALLOWED_HOSTSwhitelists the Heroku hostname and your custom domains.
4. Configure S3 storage
The production settings expect S3 credentials when you use the AWS storage option. Set them on Heroku:
heroku config:set DJANGO_AWS_ACCESS_KEY_ID="your-access-key-id"
heroku config:set DJANGO_AWS_SECRET_ACCESS_KEY="your-secret-access-key"
heroku config:set DJANGO_AWS_STORAGE_BUCKET_NAME="your-bucket-name"
Optional but often useful:
heroku config:set DJANGO_AWS_S3_REGION_NAME="us-east-1"
heroku config:set DJANGO_AWS_S3_CUSTOM_DOMAIN="cdn.example.com"
The default StaticS3Storage class uses public-read for static files. Your
bucket policy and public access settings must allow the static assets to be
served publicly, or you need to customize the storage setup before launch.
5. Configure Mailgun
Once your Mailgun domain is verified, set the required Mailgun variables:
heroku config:set MAILGUN_API_KEY="your-mailgun-api-key"
heroku config:set MAILGUN_DOMAIN="interviewdb.com"
If your Mailgun account is in the EU region, also set:
heroku config:set MAILGUN_API_URL="https://api.eu.mailgun.net/v3"
Use the dedicated Mailgun guide for the DNS setup.
6. Deploy the code
Two common deployment paths work well:
Option A: GitHub automatic deploys
Connect the repository in the Heroku dashboard under Deploy, then enable automatic deploys for your default branch.
Option B: Heroku Git
git push heroku main
Use whichever deployment flow matches how you manage the project. GitHub automatic deploys are usually the smoother long-term option once the app is connected.
7. Create the first admin user
After the first successful deploy, create a superuser:
heroku run python manage.py createsuperuser
8. Smoke test the production app
Open the app:
heroku open
If something looks wrong, tail the logs:
heroku logs --tail
Your first checks should be:
- the homepage loads
- CSS and images load correctly from S3
- the custom admin URL works
- user registration email works after Mailgun is configured
- pricing and Stripe routes load after Stripe is configured
What To Do Next
- Use Domain to point your real domain at Heroku and enable SSL.
- Use Mailgun to finish transactional email.
- Use User Authentication, Google sign-in, and Stripe to complete the product flows.