繁体   English   中英

无法连接到 Ubuntu 18.04 服务器上的 PostgreSQL db

[英]Unable to connect to PostgreSQL db on Ubuntu 18.04 Server

有时间尝试连接到 Ubuntu 18.04 服务器上的 PostgreSQL 数据库。

这是我的:postgresql.conf 文件:

port=5432
listen_addresses='*'

pg_hba.conf:

host  all  all 0.0.0.0/0 md5

防火墙当前已禁用

这是我执行命令时的 output(在另一个线程中看到这样做......): sudo netstat -ltpn

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      608/systemd-resolve 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      842/sshd            
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      2922/postgres       
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      1055/master         
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      867/nginx: master p 
tcp6       0      0 :::22                   :::*                    LISTEN      842/sshd            
tcp6       0      0 :::25                   :::*                    LISTEN      1055/master         
tcp6       0      0 :::80                   :::*                    LISTEN 

在使用以下命令进行更改时,我已经重新启动了 postgresql: sudo service postgresql restart

我尝试在 macOS 上使用 python 库 psycopg2 访问数据库并收到此错误

could not connect to server: Connection refused
Is the server running on host "<ip_address>" and accepting
TCP/IP connections on port 5432?

我错过了什么?

netstat output 很明显,您在更改listen_addresses后没有重新启动 PostgreSQL 。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM