I am trying to connect to my PostgreSQL database running in Heroku which is setup using the postgres-addon. But when I do the application crashes (I have omitted my IP and the APPS URL):
$ heroku logs --tail
› Warning: heroku update available from 7.42.0 to 7.42.2.
2020-07-29T08:53:16.308297+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/all" host=URL request_id=a80d2c63-af75-4ba4-9288-69148e2e5068 fwd="IP" dyno= connect= service= status=503 bytes= protocol=https
The way I connect to the database is
require 'pg'
class Database
def initialize
begin
@conn = PG.connect env["DATABASE_URL"]
rescue PG::Error => e
puts e.message
end
end
...
end
As soon as PG.connect is called the app crashes and I have no idea why. From what I can tell I am using the right ENV variable.
Added info:
I have realised if I use
heroku pg:psqlto connect to the database from CLI that works and I can make tables and insert entries.I tried to disable SSL mode that didn't work either
I can connect from DBeaver
heroku pg:infoandheroku pg:psql? (The latter assumes you have the Postgresql tools installed locally.) - rmlockerdsslmodeparameter.? You could try setting the env variablePGSSLMODE=disableto see if this solve the issue and then find a way to fine-tune yoursslmodein a more appropriate way. - Giuseppe Schembri