I have a deployed app that I want to make the repository public, for this, I'm using a .env to store my data, but I am having an issue when I make a request do the database, like logging.
psycopg2.OperationalError: FATAL: password authentication failed for user "$USER"
FATAL: no pg_hba.conf entry for host "FOO", user "$USER", database "FOO", SSL off
I runned: pip install django-environ
on my setting.py
import environ
env = environ.Env()
environ.Env.read_env()
SECRET_KEY = env('SECRET_KEY')
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': env('NAME'),
'HOST': env('HOST'),
'POST': 5432,
'USER': env('USER'),
'PASSWORD': env('PASSWORD'),
}
}
before that env change, I was able to connect on te site.
*DEPLOYED ON HEROKU
*I AM RUNNING THE SERVER WITH gunicorn mysite.wsgi
In Heroku, you don't have to include any .env
file instead of that you have to use the config-vars and store your secrets there.
Read more about including the config vars - https://lovekesh.tech/how-to-create-update-and-delete-config-vars-in-the-heroku-app/