【发布时间】:2016-07-01 13:16:13
【问题描述】:
我在 Mac 上使用 Postgres.app 运行 Postgres 服务器。
我正在 Node.js 中连接到服务器(代码从 Heroku docs 复制):
pg.defaults.ssl = true;
pg.connect(process.env.DATABASE_URL || 'postgres://localhost:5432/my-project', function(err, client) {
if (err) throw err;
console.log('Connected to postgres! Getting schemas...');
client
.query('SELECT table_schema,table_name FROM information_schema.tables;')
.on('row', function(row) {
console.log(JSON.stringify(row));
});
});
然后我按照说明here 允许我的 Postgres 服务器接受 SSL 连接。我在postgresql.conf 文件中将ssl 设置更改为on。我还生成了所需的文件,server.key 和 server.crt。
但是,当我运行我的节点服务器时,我收到了这个错误:
Error: The server does not support SSL connections
我跑了psql 并做了show ssl。它返回off。所以我想也许我有错误的配置文件......但后来我做了show config_file,我绝对是在正确的地方。我还缺少什么?
【问题讨论】:
标签: node.js postgresql