无法连接到服务器:拒绝连接 (0x0000274D/10061) PostgreSQL

huangapple 未分类评论49阅读模式
英文:

could not connect to server: Connection refused (0x0000274D/10061) PostgreSQL

问题

我正在使用AWS,并且想要连接PostgreSQL,但是我遇到了问题:

无法连接到服务器:

无法连接到服务器:连接被拒绝 (0x0000274D/10061)
服务器是否在主机“xx.xxx.x.x”上运行,并且接受
端口5432上的TCP/IP连接?

服务器上运行的是Ubuntu 18.04,我已经安装了PostgreSQL,并使用了以下命令:

sudo sh -c 'echo "local all all trust" >> /etc/postgresql/12/main/pg_hba.conf'
sudo sh -c 'echo "host all all 127.0.0.1/32 trust" >> /etc/postgresql/12/main/pg_hba.conf'
sudo sh -c 'echo "host all all 0.0.0.0/0 trust" >> /etc/postgresql/12/main/pg_hba.conf'
sudo nano /etc/postgresql/12/main/postgresql.conf
listen_addresses = '*'
sudo service postgresql restart

是的,我删除了 '#' 符号。

ubuntu@ip-xxxxxxxxxx:~$ sudo netstat -ltpn
活动的互联网连接(仅服务器)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      6462/nginx: master
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      629/systemd-resolve
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1040/sshd
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      20516/postgres
tcp        0      0 127.0.0.1:5433          0.0.0.0:*               LISTEN      20539/postgres
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      16863/master
tcp        0      0 0.0.0.0:5434            0.0.0.0:*               LISTEN      20517/postgres
tcp6       0      0 :::80                   :::*                    LISTEN      6462/nginx: master
tcp6       0      0 :::8080                 :::*                    LISTEN      5975/java
tcp6       0      0 :::22                   :::*                    LISTEN      1040/sshd
tcp6       0      0 :::25                   :::*                    LISTEN      16863/master
tcp6       0      0 :::5434                 :::*                    LISTEN      20517/postgres

从pgAdmin4进行连接
我做错了什么?谢谢您的回答
如果我使用了我展示的命令

ubuntu@ip-xxxxxxxx:~$ sudo -i -u postgres
postgres@ip-xxxxxxxx:~$ psql
psql (12.2 (Ubuntu 12.2-2.pgdg18.04+1),服务器 10.12 (Ubuntu 10.12-0ubuntu0.18.04.1))
英文:

I using AWS and want to connect postgresql but i have the problem

Unable to connect to server:

could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "xx.xxx.x.x" and accepting
TCP/IP connections on port 5432?

On server stay ubuntu 18.04, i installed postgres
used this command:

sudo sh -c 'echo "local all all trust" >> /etc/postgresql/12/main/bg_hba.conf'
sudo sh -c 'echo "host all all 127.0.0.1/32 trust" >> /etc/postgresql/12/main/bg_hba.conf'
sudo sh -c 'echo "host all all 0.0.0.0/0 trust" >> /etc/postgresql/12/main/bg_hba.conf'
sudo nano /etc/postgresql/12/main/postgresql.conf
listen_addresses = '*'
sudo service postgresql restart

Yes i deleted '#'

ubuntu@ip-xxxxxxxxxx:~$ sudo netstat -ltpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      6462/nginx: master
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      629/systemd-resolve
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1040/sshd
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      20516/postgres
tcp        0      0 127.0.0.1:5433          0.0.0.0:*               LISTEN      20539/postgres
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      16863/master
tcp        0      0 0.0.0.0:5434            0.0.0.0:*               LISTEN      20517/postgres
tcp6       0      0 :::80                   :::*                    LISTEN      6462/nginx: master
tcp6       0      0 :::8080                 :::*                    LISTEN      5975/java
tcp6       0      0 :::22                   :::*                    LISTEN      1040/sshd
tcp6       0      0 :::25                   :::*                    LISTEN      16863/master
tcp6       0      0 :::5434                 :::*                    LISTEN      20517/postgres

Connecting from pgAdmin4
What i didn't right? Thanks for answering
if i used commands i showed

ubuntu@ip-xxxxxxxx:~$ sudo -i -u postgres
postgres@ip-xxxxxxxx:~$ psql
psql (12.2 (Ubuntu 12.2-2.pgdg18.04+1), server 10.12 (Ubuntu 10.12-0ubuntu0.18.04.1))

答案1

得分: 0

你是否已验证了 RDS 实例的安全组?
RDS 实例位于公有子网还是私有子网?
这是内部还是外部 RDS 实例。

需要一些额外的网络设置来准确识别,然而根据提供的信息,无法连接。

英文:

Have you validated the security groups for your RDS instance?
Is the RDS instance in a public or private subnet?
Is it a internal or external RDS instance.

Need some additional network setup to accurately identify, however, from the information provided it cannot connect.

huangapple
  • 本文由 发表于 2020年5月5日 00:26:17
  • 转载请务必保留本文链接:https://java.coder-hub.com/61596968.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定