gpt4 book ai didi

postgresql - 如何修复 pgAdmin4 连接被拒绝错误

转载 作者:行者123 更新时间:2023-12-04 19:39:55 32 4
gpt4 key购买 nike

尝试在 pgAdmin4 上设置新服务器时出现此错误:

Unable to connect to server:

could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "192.168.210.146" and accepting
TCP/IP connections on port 5432?
我在我的 Windows 10 21H1 笔记本电脑上运行的虚拟机 6.1 VM 内的 CentOS 8 上运行了 postgres 12.7。我可以使用 putty 和 CentOS Web 客户端连接到操作系统。
以下是通过 CentOS Web 客户端获取的一些网络信息:
# nmap localhost         
Starting Nmap 7.70 ( https://nmap.org ) at 2021-07-14 16:59 PDT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000014s latency).
Other addresses for localhost (not scanned): ::1
Not shown: 996 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
5432/tcp open postgresql
9090/tcp open zeus-admin

Nmap done: 1 IP address (1 host up) scanned in 1.68 seconds

netstat -tlpn
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:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 954/sshd
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 972/postmaster
tcp 0 0 127.0.0.1:37753 0.0.0.0:* LISTEN 1620/cockpit-bridge

# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3
sources:
services: cockpit dhcpv6-client postgresql ssh
ports: 5432/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
#
# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.210.146 netmask 255.255.254.0 broadcast 192.168.211.255
inet6 fe80::a00:27ff:fecb:8d2d prefixlen 64 scopeid 0x20<link>
ether 08:00:27:cb:8d:2d txqueuelen 1000 (Ethernet)
RX packets 4704 bytes 512333 (500.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3757 bytes 2510585 (2.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 7252 bytes 2161674 (2.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7252 bytes 2161674 (2.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
在 PgAdmin 设置服务器屏幕中,我使用上面列出的 192.168.210.146 的 IP 地址、用户 postgres 及其密码、端口 5432 和数据库设置为 postgres。
我在尝试从我的笔记本电脑建立 odbc 和 jdbc 连接时遇到同样的错误,但我不确定 postgres 环境中需要修复什么。我确实在 pg_hba.conf 文件中添加了 1 个条目,如下所示,但这并没有帮助:
# IPv4 local connections:
host all all 127.0.0.1/32 ident
host all all 192.168.210.146/32 trust #added;not helping
是否有其他文件或设置需要修复?
谢谢。

最佳答案

解决方案是首先取消注释 postgresql.conf 中的 listen_address 条目,然后将其设置为必要的 ip 号。现在一切都很好。谢谢

关于postgresql - 如何修复 pgAdmin4 连接被拒绝错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68386440/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com