无法通过Pgadmin 4连接到远程服务器上的PostgreSQL

时间:2017-05-29 18:16:08

标签: postgresql ubuntu pgadmin-4

我最近在Azure上安装了Ubuntu 14.04。一直在尝试连接到PostgreSQL但服务器拒绝连接。我检查并确认它在线。我还尝试将设置更改为信任pg_hba.conf,我还编辑了Postgresql.conf文件以收听所有地址。此外,我检查了Windows上的防火墙设置,并允许Pgadmin 4通过。尽管遵循了这个问题(Unable to connect PostgreSQL to remote database using pgAdmin)中的所有说明,但我无法连接。我该怎么办?

2 个答案:

答案 0 :(得分:0)

启用postgresql服务器以启动

启动
sudo systemctl enable postgresql

启动postgresql服务器

sudo systemctl start postgresql

验证你的postgresql服务器是否正在运行:

sudo systemctl status postgresql

答案 1 :(得分:0)

我曾经在win 10上遇到过pgAdmin4的问题。这是我连接到远程服务器所采取的步骤

首先启用端口5432,使其通过ubuntu中的防火墙:

sudo ufw allow 5432/tcp

然后编辑您的postgresql.conf文件并添加

listen_addresses =“ *”

文件可以在/etc/postgresql//main/postgresql.conf中找到

继续编辑pg_hba.conf并添加

host   all   all  0.0.0.0/0   md5

现在使用/etc/init.d/postgresql stop停止服务器,然后重新启动/etc/init.d/postgresql start

您现在应该可以连接。但是,您可以允许pgAdmin4通过Windows防火墙

control panel > System and Security > Allow an app through windows firewall

您还可以为已安装的任何防病毒软件允许同一应用

注意: 如果仍然无法连接,则可以重置您的postgres用户密码 Linux默认用户

sudo -u postgres psql postgres
# \password postgres
Enter new password

然后使用此新密码通过以下方式连接您的pgAdmin4

  • postgres作为维护数据库

  • postgres作为用户名

  • 然后输入新密码

希望您应该能够连接

相关问题