postgresql – 无法从远程主机连接到postgres
发布时间:2020-12-13 16:42:02 所属栏目:百科 来源:网络整理
导读:我有一个数据库服务器(192.168.1.50)运行postgres。我创建了一个名为“testdb”的数据库和一个用户“testuser”,密码为“testuserpw”。 在本地,我可以使用以下命令连接到数据库: psql -d testdb -U testuser 当我从另一个主机(192.168.1.60)发出命令时:
我有一个数据库服务器(192.168.1.50)运行postgres。我创建了一个名为“testdb”的数据库和一个用户“testuser”,密码为“testuserpw”。
在本地,我可以使用以下命令连接到数据库: psql -d testdb -U testuser 当我从另一个主机(192.168.1.60)发出命令时: psql -h 192.168.1.50 -d testdb -U testuser 我有错误: psql: could not connect to server: Connection refused Is the server running on host "192.168.1.50" and accepting TCP/IP connections on port 5432? 任何想法 ?
检查postgresql.conf文件中listen_addresses的设置。许多发行版默认为127.0.0.1,即仅侦听从本地主机进入的连接。应将其设置为“*”以监听所有接口上的连接。
如果您仍然遇到问题,请使用lsof查看postgres进程正在侦听的网络套接字。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |