Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Heroku database showing password authentication failed after maintenance

So i received a message from heroku saying it needs to carry out maintenance on my database and will be read only for a bit. However I go to check my site and the site isn’t working for the pages that require data from the database, I go to check the logs and see this error message:

2022-05-20T09:57:55.246102+00:00 app[web.1]: sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server at "eu-west-1.compute.amazonaws.com" (52.18.116.67), port 5432 failed: FATAL:  password authentication failed for user "MYUSERNAME"
2022-05-20T09:57:55.246102+00:00 app[web.1]: connection to server at ".eu-west-1.compute.amazonaws.com" (52.18.116.67), port 5432 failed: FATAL:  no pg_hba.conf entry for host "IP", user "MYUSERNAME", database "DATABASE", no encryption

I haven’t touched or changed anything, so not sure what the problem is.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This happen if you are not using the "dynamic" environment variable that Heroku manage for connecting to a PostgreSQL database

If you have just one, it’s better to use DATABASE_URL as it always have up-to-date location and credentials

Heroku can change the url for various reasons, ex credentials rotation

If you are using sqlalchemy you might need a slight workaround:

os.environ.get('DATABASE_URL').replace('postgres://', 'postgresql://')
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading