error: connection to server at "10.0.30.7", port 5432 failed: No route to host

545 Views Asked by At

at first, I want a HA PostgreSQL by repmgr

subnet its 10.0.30.0/24

da1 server 10.0.30.7 -- master da2 server 10.0.30.6 -- worker so i get error

postgres@da2:~$ repmgr -h 10.0.30.7 -U repmgr -d repmgr -f repmgr.conf standby clone --dry-run NOTICE: destination directory "/var/lib/postgresql/15/main" provided INFO: connecting to source node DETAIL: connection string is: host=10.0.30.7 user=repmgr dbname=repmgr ERROR: connection to database failed DETAIL: connection to server at "10.0.30.7", port 5432 failed: No route to host Is the server running on that host and accepting TCP/IP connections?

i can ssh

postgres@da2:~$ ssh [email protected] [email protected]'s password:

My postgresql.conf file: `listen_addresses = '*' port = 5432

`

the da1 server - master - pg_heba.conf

da1 : 

# Database administrative login by Unix domain socket
local   all             postgres                                peer
local   all             repmgr                                  peer 
# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             all             10.0.30.0/24            md5
# "local" is for Unix domain socket connections only
local   repmgr          repmgr                                  trust
local   all             all                                     peer
# IPv4 local connections:
host    repmgr          repmgr          10.0.30.0/24            trust
host    all             all             10.0.30.0/24            md5
host    all             all             0.0.0.0/0               md5
# IPv6 local connections:
host    all             all             0.0.0.0/0               md5
host    all             all             ::1/128                 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     repmgr                                  trust
local   replication     all                                     peer
host    replication     repmgr          10.0.30.0/24            trust
host    replication     replicador      10.0.30.0/24            md5
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256

and da2 :

the da2 : 

# Database administrative login by Unix domain socket
local    all             postgres                                peer
#local   all             repmgr                                  peer 
# TYPE  DATABASE        USER            ADDRESS                 METHOD
host     repmgr         repmgr         10.0.30.7/24              md5
host      all           all            10.0.30.0/24              md5
# "local" is for Unix domain socket connections only
local   all             all                                      peer
# IPv4 local connections:
host    all             all             10.0.30.0/24             md5
# IPv6 local connections:
#host    all             all                             md5
host    all             all             ::1/128                 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256

I check almost everything still unable to connect

2

There are 2 best solutions below

2
On

have you check your firewall rules? can you do telnet from da1 to da2 on port 5432? Please in the two server, please run: netstat -plntu and return the result (you must install net-tools to run netstat)

1
On

The error No route to host suggests that there is no route for the server IP address in the client's routing table. Are you able to ping the server's IP address? You most likely will not be able to and ping would say that the server is not reachable. If so, then this error has nothing to do with your configuration, you are probably running into a network connectivity issue. You might want to check your firewall rules.