Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Python & Postgres Heroku Deployment

Python Heroku Deployment

Steps to create a postgres database and deply a Python app to Heroku

Install guinicorn locally

pipenv install gunicorn
pip install gunicorn

Install Heroku CLI

Login via CLI

heroku login

Create app

heroku create appname

Create database

heroku addons:create heroku-postgresql:hobby-dev --app appname


heroku config --app appname

# Add to your app

Create Procfile

touch Procfile

# Add this
web: gunicorn app:app

Create requirements.txt

pip freeze > requirements.txt

Create runtime.txt

touch runtime.txt

# Add this

Deploy with Git

git init
git add . && git commit -m 'Deploy'
heroku git:remote -a appname
git push heroku master

Add table to remote database

heroku run python
>>> from app import db
>>> db.create_all()

Visit app

heroku open
Copy link

esha123802 commented Jul 17, 2021

im at this part already, im having this problem, i appreciate any sort of help I can get.

Im having the same error, did you figure it out? I have added the bin path to env also

Copy link

srinumadhavv commented Aug 12, 2021

Everything is running fine but unable to access the database , it says table not found

Copy link

lena-A-Al commented May 12, 2022

heroku open
is not working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment