Can't connect to postres

I have a Postgres DB with whitelisted IP of 0.0.0.0. Render updates it to 0.0.0.0/32 when I save it. The little utility to test says it works. But when I start my app it says the SSL connection was terminated unexpectedly.

I wrote a basic script to test the connection in ruby.

require ‘pg’

Replace the placeholders with your actual database credentials

url = “postgresql://username:password@hostname:port/database”

begin
conn = PG.connect(url)
puts “Connected to PostgreSQL database”

You can now use the ‘conn’ object to interact with the database

rescue PG::Error => e
puts “Error connecting to the database: #{e.message}”
ensure
conn.close if conn
end

This also fails with this message

Error connecting to the database: connection to server at “35.227.164.209”, port 5432 failed: SSL connection has been closed unexpectedly
ruby(38904,0x1def65300) malloc: double free for ptr 0x143808200
ruby(38904,0x1def65300) malloc: *** set a breakpoint in malloc_error_break to debug

Thanks for any help.

Hi Tomasz,

We have a handful of reports of this, it appears to be either a bug in OpenSSL 3.2.0. The most canonical report I’ve found is openssl@3.2.0 update makes psql crash when connecting with TLS · Issue #155651 · Homebrew/homebrew-core · GitHub

The important detail here are the two lunes:

malloc: double free for ptr 0xnnnnnn
malloc: *** set a breakpoint in malloc_error_break to debug

These lines, and even more specifically the “double free” line, are indicative of this incompatible OpenSSL version case.

There are many cases when the larger “SSL connection has been closed unexpectedly” error occurs, but double free indicates the current specific issue.

There are a handful of recommendations in that link I provided, according to the last comment in that thread re-building Postgres and libpq via Homebrew should fix it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.