【发布时间】:2017-10-28 19:46:52
【问题描述】:
尝试连接Postgres Node js,遇到错误
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
如何关闭 SSL 连接?这是我的环境设置
DB_HOST=localhost
DB_USER=postgres
DB_PASS=password
DB_NAME=dbname
DB_SSL=true if heroku
DB_PORT=5432
还有我的 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'
}
}
};
由于我在 dev 中运行,我预计它不会通过 SSL。也尝试从对象和 URL 中删除该 SSL 部分。没有运气。
【问题讨论】:
-
如果您没有添加任何技巧来使 ssl 工作,knex 将不会尝试使用 ssl 连接来连接 postgres。您确定这是删除配置的 SSL 部分后遇到的错误吗?您确定您使用的是该 knexfile 进行连接吗?
标签: node.js postgresql knex.js