簡體   English   中英

如何修復 pgAdmin4 連接被拒絕錯誤

[英]How to fix pgAdmin4 connection refused error

嘗試在 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 設置服務器屏幕中,我使用上面列出的 IP 地址 192.168.210.146、用戶 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 號。 現在一切都連接得很好。 謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM