Is it possible to force a database credential update on Heroku? - heroku

Heroku sent an email regarding scheduled maintenance for a hobby-dev hosted Postgres database I have. I received confirmation that the scheduled maintenance had been successfully completed and that my updated database credentials would reflect this.
After updating the environment variables in my app to reflect this change, I can no longer connect to the database. Scheduled maintenance changes have completed before with no issues, this is the first time I'm receiving this error.
Authentication failed against database server at `ec2-176-34-114-78.eu-west-1.compute.amazonaws.com`, the provided database credentials for `mydb` are not valid.
However, when I log into Heroku to view the database instance, the health checks are showing that it's available.
I've now tried using the new and old database credentials, but both are unable to connect to the DB. It also appears that I am unable to directly contact support on the hobby dev plan.
Do I have any other options to try troubleshoot this? Is it possible to force a new database credential update on Heroku?

Yes, you can use heroku pg:credentials:rotate to generate new credentials. But you shouldn't have to do this.
After updating the environment variables in my app to reflect this change
As the email told you, your credentials would automatically have been updated. There was nothing for you to do. As long as you are connecting via the DATABASE_URL environment variable, which is always recommended with Heroku Postgres¹, you should be good to go.
heroku pg:credentials:rotate behaves the same way, so running that command without understanding this isn't likely to help much.
¹Heroku may update these credentials at any time. Connecting via that environment variable is the best way to ensure you can always connect.

Related

Why do I lose contents of my database after a heroku dyno restart?

Anytime my app goes to sleep and comes back on, I lose data in my database
And I'm not storing any media, it's just form data (texts)... I built the app on strapi and I've followed all their guidelines but it keeps happening. I'd be happy if anyone can help
Local data (files, db) is cleared after a Dyno restart because the Heroku File System is ephemeral. A Dyno is restarted (at least) every 24hrs.
In your case Strapi uses SQLite where data is saved in a local file.
Strapi suggests to configure Postgres on Heroku, alternatively you can use an external DB storage service.
First of all:
As you create content types with strapi it generates the code (= new files) for the according controllers/routes/services
Heroku does not persist data after a restart
After a restart strapi checks which content types exist in the code and deletes the tables of nonexisting types from the database.
Therefore, on Heroku you have to set up all your content types locally and connect to an external db (e.g. Heroku Postgres) but never strapi's default textfile based db.
Then push the generated files and finally deploy.
Thus, on Heroku you should always run in production mode. This way the option to alter content types is completely blocked and you will not run into the issue of data loss after a restart.

Politics of change of credentials on Heroku-Postgres

I had my application configured and deployed with a database that already had some records, today without knowing why the credentials have changed and with it the access to the database.
I would like to know under what parameters and how often Heroku does this kind of thing.

How do I access Heroku Postgres DB from an external application using latest credentials?

I am building an ETL Application that needs to fetch data from Heroku Postgres DB a few times a day but the application is not running on Heroku, I am already able to do this, but using the current credentials, but heroku states that the credentials are not permanent and will be rotated from time to time.
What is the best way to do this, building a REST API on top of my app is not viable an option. I have seen that Heroku provides a config vars API which I could potentially use to fetch the DB credentials, but is there a simpler/cleaner way for implementing this, is enforcing permanent credentials an option?
There is no way to enforce it. And it's not a question of credentials, but a question of a database hostname. It's ec2.
Your safest bet is to always fetch current DATABASE_URL from your Heroku app. If you only need to do it 'a few times a day' this is not a problem.

Trying to setup heroku app on my pc

I am going through the getting started guide with heroku and I hit a snag, cannot seem to access the remote database it connects but there is no database name. I have installed postgres sql 9.5 locally but attempting to push the local database I created fails also and when i run heroku pg:info it never responds.
I am going through the documentation but there is a lot of it, so hopefully some psql wizard will see this and go, oh this is what he is doing wrong and let me know.
It's likely that you have not "Created" the database. rake db:create - This needs to be done on Heroku's servers and your local machine.
Not quite correct,I am not using ruby, one major caveat I did not notice initially is that I was not in the bash shell which might have been part of my problem, what i wound up doing was connecting to the postgresql remote instance from my local install using pgadmin and creating the table manually from there. I had to get the connection info which I obtained by using heroku pg:credentials DATABASE which gave me the info I needed to add the server in pgadmin, you do need to check ssl for that within the tool, and it helps to add the database name to restricted so you see only your database, not the whole 10 gazillion they have in production :) I hope this helps anyone else that has the same problem.
Thanks

How configure a shared database with Play/Heroku?

I started by defining a framework ID as specified here
http://www.playframework.org/documentation/1.2/guide11
I called my server appnameheroku
Then I retrieved the database URL using
heroku config
from the console
I then added the following two lines to application.conf
%appnameheroku.jpa.ddl=validate
appnameheroku.db=postgres://....compute-1.amazonaws.com/etc
I then deploy the app and get the following error
Oops, an error occured
This exception has been logged with id 6963iilc8. I'm using the free version of Heroku.
Two things here: Storing config in the application code is a bad idea, as it prevents Heroku from carrying out a lot of administrative tasks on your behalf.
Therefore I would configure my application.conf as:
db=${DATABASE_URL}
jpa.dialect=org.hibernate.dialect.PostgreSQLDialect
jpa.ddl=update
Heroku don’t recommend setting jpa.ddl to update for a real world production app. Use Play!’s database evolutions instead.

Resources