"password authentication failed" for user after moving the credentials to .env file
I'm just trying to figure out this issue of "port 5432 failed: FATAL: password authentication failed for user "username" connection to server at "localhost"". The below code works fine in the dev environment but after I host it to Digital ocean it is not working. My setting.py code is
config = environ.Env()
# reading .env file
environ.Env.read_env()
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": config("DB_NAME"),
"USER": config("DB_USER"),
"PASSWORD": config("DB_PASSWORD"),
"HOST": config("DB_HOST"),
"PORT": config("DB_PORT"),
}
}
and the .env file is like
SECRET_KEY=#$@#$@#$$##$%^%^&%^$#%#$%#$%
DEBUG=True
DB_NAME=polymath_core
DB_USER=dc_user
DB_PASSWORD=#$#$$%#$#%$###$
DB_HOST=localhost
DB_PORT=5432
and the error
django.db.utils.OperationalError: connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user "dc_user"
connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user "dc_user"
The pg_hba.config
Just cant figure this out. Any help would be appreciated.
Thanks