2017-05-28 21 views
2

PostgresのノードのjsとエラーSSL接続をオフにする方法Knex:エラーpool2は - エラー:サーバーがSSL接続をサポートしていません

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 

に走っに接続しようとすると?ここに私の環境設定

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

をそして、私はDEVで実行しておりますので、私の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' 
    } 
    } 

}; 

ですが、私はそれがSSLを経由しないであろうことを期待しました。そのSSL部分をオブジェクトやURLからも削除しようとしました。運がない。

+0

あなたはSSLを機能させるためにあらゆる策略を追加していない場合は、knexをしようとはしませんpostgresとssl接続を接続します。設定のSSL部分を削除した後にエラーが表示されますか?そのknexfileを使用して接続していますか? –

答えて

0

明示的に求められていないときにknexが強制的にssl接続を使用しようとする理由はありません(実際にはpgドライバがその部分を処理します)。

あなたはHerokuのを接続し、その上に、より複雑な構成を動作させる基盤としてこれを使用することもできます。

const knex = require('knex')({ 
    client: 'pg', 
    connection: 'postgres://user:[email protected]:port/database' 
}); 

knex.raw('select 1') 
    .then(res => { 
    console.log('Success'); 
    }) 
    .catch(err => { 
    console.log('Something failed', err); 
    }); 
関連する問題