Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Knex:Error Pool2 - Error: The server does not support SSL connections

Trying to connect with Postgres Node js and ran into the error

Resource Wall is listening on port 8080
Knex:Error Pool2 - Error: The server does not support SSL connections
Knex:Error Pool2 - Error: The server does not support SSL connections

How to turn off SSL connection? Here is my environment setup

    DB_HOST=localhost
    DB_USER=postgres
    DB_PASS=password
    DB_NAME=dbname
    DB_SSL=true if heroku
    DB_PORT=5432

And my knexfile.js

require('dotenv').config();

module.exports = {

  development: {
    client: 'postgresql',
    connection: {
      host     : process.env.DB_HOST,
      user     : process.env.DB_USER,
      password : process.env.DB_PASS,
      database : process.env.DB_NAME,
      port     : process.env.DB_PORT,
      ssl      : process.env.DB_SSL
    },
    migrations: {
      directory: './db/migrations',
      tableName: 'migrations'
    },
    seeds: {
      directory: './db/seeds'
    }
  },

  production: {
    client: 'postgresql',
    connection: process.env.DATABASE_URL + '?ssl=true',
    pool: {
      min: 2,
      max: 10
    },
    migrations: {
      tableName: 'migrations'
    }
  }

};

Since I am running in dev, I expected that it won't go through SSL. Tried removing that SSL part from object and URL too. No luck.

like image 394
Suresh Atta Avatar asked Nov 23 '25 23:11

Suresh Atta


1 Answers

There is no reason why knex would try to force using ssl connection when it is not explicitly asked to do that (well actually pg driver takes care of that part).

You may want to use this as a base to connect heroku and then work more complex configuration on top of this:

const knex = require('knex')({
  client: 'pg',
  connection: 'postgres://user:pass@server:port/database'
});

knex.raw('select 1')
  .then(res => {
    console.log('Success');
  })
  .catch(err => {
    console.log('Something failed', err);
  });
like image 156
Mikael Lepistö Avatar answered Nov 26 '25 14:11

Mikael Lepistö



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!