[英]Unable to connect to PostgreSQL db on Ubuntu 18.04 Server
Having a time trying to connect to a PostgreSQL database on Ubuntu 18.04 server.有时间尝试连接到 Ubuntu 18.04 服务器上的 PostgreSQL 数据库。
Here is my: postgresql.conf file:这是我的:postgresql.conf 文件:
port=5432
listen_addresses='*'
pg_hba.conf: pg_hba.conf:
host all all 0.0.0.0/0 md5
firewall is currently disabled防火墙当前已禁用
here is the output when I did the command (saw in another thread to do this...): sudo netstat -ltpn
这是我执行命令时的 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
I have restarted postgresql each when making a change using the command: sudo service postgresql restart
.在使用以下命令进行更改时,我已经重新启动了 postgresql: sudo service postgresql restart
。
I have tried to access the db using the python library psycopg2 on macOS and getting this error我尝试在 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?
What am I missing?我错过了什么?
From the netstat
output it is obvious that you didn't restart PostgreSQL after changing listen_addresses
.从netstat
output 很明显,您在更改listen_addresses
后没有重新启动 PostgreSQL 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.