I am setting up a server that has more than one Postgres cluster running. By default, I set the main postgres
cluster (the one whose default port is 5432) to not start automatically with the computer. I set, instead, two other Postgres clusters to start, one at port 5433 and the other at 5434.
All seems to be working perfectly fine, with one critical exception: I can't login to those clusters remotely. That is, when I try:
psql -h [my server ip] -p 5433 -U myusername -d mydatabase
I get:
psql: could not connect to server: Connection refused Is the server running on host "[my server IP here]" and accepting TCP/IP connections on port 5433?
Now, I know that past questions have been already asked on this issue. See for instance: "psql: could not connect to server: Connection refused" Error when connecting to remote database
However, I did follow all possible steps I found online. Let's see. All my Postgres clusters have their postgresql.conf
already with listen_addresses = '*'
(uncommented). Similarly, all my clusters' pg_hba.conf
have host all all 0.0.0.0/0 md5
and host all all all md5
.
I did open ports 5432, 5433 and 5434 with:
sudo ufw allow 5432/tcp
sudo ufw allow 5433/tcp
sudo ufw allow 5434/tcp
And I did restart the postgres services. In fact, I restarted the whole server machine. So now when I run sudo netstat -ltpn | grep "postgres"
I get, for instance, for cluster at port 5433:
tcp 0 0 0.0.0.0:5433 0.0.0.0:* LISTEN 3227/postgres
tcp6 0 0 :::5433 :::* LISTEN 3227/postgres
Still, remote connection to the Postgres cluster is not possible and throws the above mentioned error. What else can I try?