如何使用pg-promise连接到没有密码的Postgres数据库? [英] How do you connect to a Postgres Database with no password using pg-promise?

查看:114
本文介绍了如何使用pg-promise连接到没有密码的Postgres数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试初始化与我的PG数据库的连接:

I am trying to initialize a connection to my PG database doing this:

    pgp = require('pg-promise')({
    // Initialization Options
}),
cn = {
    host: 'activity.postgres.activity', // server name or IP address;
    port: 5432,
    database: 'activity',
    user: 'postgres',
    password: ''
},
db = pgp(cn),

但我一直在获取:


错误:连接ECONNREFUSED 172.20.0.3:5432

Error: connect ECONNREFUSED 172.20.0.3:5432

任何想法为什么?

已解决:
在postgresql.conf文件中设置了listen_addresses ='*'

RESOLVED: set the listen_addresses = '*' in the postgresql.conf file

推荐答案

问题与您使用的库或密码无关。

The issue is not with the library you are using or the password.

该错误告诉您没有可用的服务器

The error tells you that there is no server available at that IP/port.

另请参见: node-postgres出错,连接ECONNREFUSED

ie首先检查您可以通过PSQL连接到它。

i.e. check first that you can connect to it via PSQL.

这篇关于如何使用pg-promise连接到没有密码的Postgres数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆