【发布时间】:2020-02-23 13:55:20
【问题描述】:
在尝试连接到我的 PostgreSQL 实例很多天后,我决定是时候寻求帮助了。
我正在尝试从 Windows 机器连接到我的 PostgreSQL 数据库。
我正在尝试 pgAdmin 4 和 dBeaver,但都无法连接。下面是我使用dBeaver连接时收到的错误截图。
我正在创建的连接是这样的:
我的用户是 (\du):
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
umberto | Superuser, Create role, Create DB | {}
我的数据库 (\l):
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+---------+---------+-----------------------
postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
umberto | umberto | UTF8 | C.UTF-8 | C.UTF-8 |
wondermap | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
不知道在哪里搜索日志以深入了解服务器计算机上的此问题。我唯一能找到的是文件夹/var/log/postgresql,在该文件夹中我只看到两个非 gzip 压缩文件,但这些消息指的是我尝试连接之前的几天。
最后,我的pg_hba.conf:
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::1/128 md5
host all all ::0/0 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
host all all ::/0 md5
可能是什么问题?
【问题讨论】:
-
我认为您没有明确说过,但我认为 postgres 运行在与您连接的计算机不同的计算机上?如果是这种情况,那么很可能是防火墙或类似的连接问题,而不是 postgres。如果它被 pg_hba.conf 设置拒绝,您将不会收到超时错误。 也许 postgres 没有在预期的端口上运行或监听,但这比拒绝服务器端之间或服务器端的连接的可能性要小。
-
是的,它在另一台机器上。我确保服务器端端口 5432 已打开。会不会是客户端防火墙?
-
如果客户端 = 您则不,除非您阻止出站连接,这有点不寻常。从您的客户端您可以从 Microsoft 下载 portqry,然后尝试
portqry -n [pg host name] -e 5432看看结果如何。 “正在侦听”=能够访问服务器上的该端口,并且某些东西(希望是 pg)正在侦听该端口; “未监听” = 您可以访问该端口,但没有任何内容在监听(可能导致超时); “已过滤” = 访问被阻止,几乎可以肯定是由于防火墙。 -
是的,我收到了
FILTERED。感谢您的 cmets,我现在可以解决我的问题。非常感谢您的帮助,如果您愿意,可以发布您的 cmets 作为答案,我很乐意接受。干杯! -
非常希望它能帮助您找到确切的问题。我现在已经把它作为答案发布了。
标签: postgresql database-connection pgadmin dbeaver