Application crashes after "Update DATABASE by heroku-postgresql" - postgresql

Since yesterday, when heroku-postgresql made an automatic update to the add-on, the application doesn't open anymore. Instead, it crashed with a
"error error: password authentication failed for user "neyzbgqnexgsom"" message that I can see in the Heroku logs tail.
My app was working fine for about 3 months, and it started crashing right after this. How can I make it work back again?

I found out that after that update, the DATABASE_URL config variable has changed. You must populate the Config Vars once again with the new values from the DATABASE_URL.

Related

PG::connectionBad error in logs for Rails 5 heroku app, is mismatched IPs the reason?

Heroku deleted my rails 5 app's database. I created a new DB, they recovered the old one and copied it to the new one, then attached it. But my site won't load. Heroku support hasn't tried to help beyond giving links to troubleshooting I've done many times. I've been trying every possible fix I can find for a week.
In the error message, I noticed the host that is listed for my database in the settings does not match the host in the timeout error.
MY HOST (per heroku settings): ec2-18-2XX-36-213.compute-1.amazonaws.com
The host in the logs: ec2-5X-83-25-2X7.compute-1.amazonaws.com
(I replaced a couple numbers with X b/c Idk if that's sensitive information)
Is that why the connection won't work? If so, how do I fix it?
FATAL -- : [465fe0b0-f387-4b4a-b215-779dbb8dbf7e] PG::ConnectionBad (connection to server at "ec2-5X-83-25-2X7.compute-1.amazonaws.com" (5X.83.25.2X7), port 5432 failed: Connection timed out
Turns out, all I needed to do was go into my new database's settings, copy the DATABASE_URL, go into the config vars of my app, and paste over the old DATABASE_URL.
So many wasted hours because heroku tech support couldn't articulate that. Took 5 seconds, then site loaded immediately. Didn't need to push anything, commit anything, change any code, etc

Heroku wrong credentials for postgresql database

i’m using heroku for deploy a database (postgres) and connect to it.
I used it for 2 weeks but today it start rejecting my credential and i couldn’t login anymore, i checked if the credential are changed but nothing?
Can anyone help me? thanks a lot!
I had this issue, if you look in the Settings -> Config Vars you will see that the DATABASE_URL has changed. So you need to use the new value in Datagrip and things will work again.
They change the details periodically but it doesn't seem to update in the database settings page which is very annoying although it only happens on the free tier.

my postgres is unable to connect ever since heroku did a maintenance update 12 hours ago

anyone facing something similar? sadly I'm on a free plan so I can't open a ticket... does anyone know of a way to restart the service/machine of the DB? maybe that would just solve it...
ok so the issue in my case is that indeed heroku performed some sort of maintenance on the DB, and apparently it's connection params (host/url/user/password) had changed... and since it was embedded throughout all my interfaces (the app, my db tools, admin app I also have) - none were able to connect (they'd timeout).
while trying to figure out, I used the wonderful CLI tools of heroku pg:info and heroku pg:diagnose and even heroku pg:psql and tested to see that my data is still there... eventually I went to the online admin and that's where I saw the connections params had changed. BTW - I have this project for 2 years and this is the first time this had happened...
I was in the same situation. Heroku will email you that your database is scheduled for maintenance. After it's complete, connecting to the database fails because of this error:
error: no pg_hba.conf entry for host "IP_ADDRESS", user "DB_USER", database "DB_NAME", no encryption
This is telling us that incorrect credentials were given, meaning the database connection string has changed. I first checked the credentials on the website for the Heroku Postgres Add-on (data.heroku.com), but the connection string was still the same as before; it has not updated or changed at all, therefore this was misleading. Instead, the updated connection string is found inside of the DATABASE_URL config variable, located in the Settings tab of your app on the Heroku dashboard (dashboard.heroku.com), under Config Vars. To avoid manually correcting this problem again, get the connection string from the DATABASE_URL config variable directly, as opposed to hard coding it in your app.
Yes, Im in the same situation. Heroku are a bunch of amateurs. They did some maintenance on the DB, and after it was done, credentials don't work, even those listed in admin/dashboard section of web. Bunch of loosers... #heroku

Heroku Postgres app works on local machine but not on Heroku

I built and deployed a Node.js Postgres app to Heroku and can not get to any of my endpoints via the Heroku site except the root GET route. Curiously, when I run Heroku local web ALL my endpoints behave exactly as they should. I can successfully perform CRUD on the app running via Heroku local web. However, when I try, for instance, to create a user using the Heroku URL, it returns an empty error message. Yet, when I check the associated database I find that the user was indeed created. Other than returning an empty error message when I try to either create a user or sign it, the app correctly responds with the different errors I programmed. For example, when I tweak my login details or try to register the same user I earlier tried to register it correctly says the user already exists!. Still, when I try to log in that same existing user I get a blank error message. Note that I created both the Heroku PostgreSQL database and my local PostgreSQL database from exactly the same queries. Please, can you help me through this bottleneck? I am using Postman to test my APIs.
Test to sign in user on Heroku app running on the local machine: success!
Same exact test with Heroku URL: cryptic error.
Ok, so after a lot of researching and fiddling around I discovered the solution. I did not add keys from my .env file to Heroku as config vars found under the settings tab of the Heroku User dashboard. Manually adding my environment variables resolved the matter. Now my app is working both on my local machine and via the Heroku URL.

Cannot connect to Heroku MongoDB

I created an Ionic app with NodeJS backend and Mongo database and deployed it to Heroku (with mLab MongoDB add-on). It worked well for a day. The next day I was unable to connect to the DB. The app went to sleep in the meantime, but when I opened it in the browser it woke up. I know that because I saw the static text that I put on the index page. But a few seconds later, an error page appeared. From the console and network tabs output I could figure out that the app is unable to access the database and to fetch data.
I found a post on the internet where the author said that he had the same issue and that he deleted the db instance on Heroku and created a new one. So I did the same and then I was able to start my app normally again.
Today the same thing happened - I can't connect. When I switch the DB URI in the code to mongodb://localhost/mydbname and run the application locally, it works perfectly, so I concluded that the app code itself is fine, there's only an issue with connecting to the DB. It also wouldn't work locally if I try to target the DB on Heroku.
I thought that I might forgot the credentials, so I went to the Heroku dashboard and changed both the username and the password. Then I tried to connect through the console with mongo ds<number>.mlab.com:<port>/heroku_<name> -u <username> -p <password>. Here's the output:
MongoDB shell version v3.6.3
connecting to: mongodb://ds213239.mlab.com:13239/heroku_d3xjtj3x
2018-03-16T16:09:18.215+0100 W NETWORK [thread1] Failed to connect to 54.236.230.76:13239 after 5000ms milliseconds, giving up.
2018-03-16T16:09:18.216+0100 E QUERY [thread1] Error: couldn't connect to server ds213239.mlab.com:13239, connection attempt failed :
connect#src/mongo/shell/mongo.js:251:13
#(connect):1:6
exception: connect failed
Currently I'm using free version of both hosting and DB add-on, because I want only to test the app and to show it to my client (who will then decide if he wants to pay for the Heroku services). If I have nothing to show and if this happens each time, well, that would suck.
And here's the fun part: I wanted to try to open the app one more time so that I could copy and paste the exact error message here. And this time it worked normally! (???) The only thing I did is that I changed the username and pass on the DB dashboard, but I didn't push the updated code and I also didn't change it in the MONGODB_URI config variable.
Does anyone have an idea why does this happen? Is there a way to keep the DB awake and accessible (without paying extra)?
Thanks.
EDIT: It doesn't work again!!! Literally 30 seconds after submitting this post I tried to access the app again and it didn't work! There is an error page which says:
Error: Uncaught (in promise): [object Object]
at c (http://localhost:8100/build/polyfills.js:3:19752)
at c (http://localhost:8100/build/polyfills.js:3:19461)
at http://localhost:8100/build/polyfills.js:3:20233
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15660)
at Object.onInvokeTask (http://localhost:8100/build/vendor.js:4973:33)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15581)
at r.runTask (http://localhost:8100/build/polyfills.js:3:10834)
at o (http://localhost:8100/build/polyfills.js:3:7894)
at e.invokeTask [as invoke] (http://localhost:8100/build/polyfills.js:3:16823)
at p (http://localhost:8100/build/polyfills.js:2:27648)
ONE MORE EDIT: I deleted the DB again, created a new one, changed the connection string in my app and pushed the changes. Now it works normally. I'll check again tomorrow and update this post.
NEW EDIT: One day later, the app doesn't connect to the DB again. And again I get the same error message.
Wtf, Heroku???