4

It seems after my database was upgraded to 10.2 I'm unable to connect.

I'm using the pg 7.4.2 npm package.

To be clear, I have been connecting without issue for 6 months using the same connection string which had ?ssl=true appended to it.

I get this error connecting via Pool or Client.

AssertionError [ERR_ASSERTION]: false == true
    at Object.exports.connect (_tls_wrap.js:1099:3)
    at Socket.<anonymous> (/home/e/express/testpg/node_modules/pg/lib/connection.js:94:23)
    at Object.onceWrapper (events.js:219:13)
    at Socket.emit (events.js:127:13)
    at Socket.emit (domain.js:421:20)
    at addChunk (_stream_readable.js:269:12)
    at readableAddChunk (_stream_readable.js:256:11)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onread (net.js:598:20)

I'm now hardcoding the full postgres connection string so there is no issue with env variables.

I've tried adding/removing ?ssl=true to the end of the connection string and adding/removing ssl:true from the constructor. I've also tried with and without promises. Same error no matter what on both local and deployed to heroku.

imports:

import { Pool, Client } from 'pg'

method 1:

let pool = new Pool({
  connectionString: csnew,
  ssl: true
})

pool.connect().then( client => {
  console.log('connected')
})
.catch(e=> {
  console.log(e)
})

method 2:

let pgclient = new Client({
  connectionString: csnew,
  ssl: true
})
pgclient.connect().then( () => {
  console.log('connected')
}).catch(e=> {
  console.log(e)
})

1 Answer 1

4

That's because v7.4.2 broke its SSL support. Here's the open issue.

You need to use strictly v7.4.1 till the issue is resolved.

UPDATE

Version 7.4.3 fixed the issue.

Sign up to request clarification or add additional context in comments.

3 Comments

Downgrading to 7.4.1 is working for us thanks to @vitaly-t
@647er maybe that you have to remove the ^ before the targeted version in your package.json
@647er You either included it as "^7.0.0", or didn't re-install correctly. The issue didn't exist prior to v7.4.2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.