I have tried everything I could find to establish a remote connection to my Postgres 9.6 database running on a CentOS 7 gcloud VM.
I have set the following in pg_hba.conf:
host all all MYPUBLICIP/24 md5
postgres.conf:
listen_addresses = '*'
port = 5432
Setup firewalld like in this article: How to Configure 'FirewallD' in RHEL/CentOS 7 and Fedora 21 - Part 3
Result of firewall-cmd --list-all
:
trusted (active)
target: ACCEPT
icmp-block-inversion: no
interfaces:
sources: 50.236.122.225/24
services: postgresql
ports: 5432/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
There is no interface. I tried adding one using firewall-cmd --zone=public --change-interface=eth0
but that did change anything.
I tried using iptables instead but without success. Iptables is now removed so it cannot interfere.
firewalld
andpostgresql
, did you restart each service? Does the client that you're trying to connect from actually have the ip address of50.236.122.225
? Also, inpg_hba.conf, instead of
MYPUBLICIP/24, use
0.0.0.0/0` underremote connections
.firewall-cmd --list-all
though, even though I removed it! Tried changing to 0.0.0.0/0 md5 in postgres config but still connections all time outtrusted
zone and not in thepublic
zone. Be sure that your interface and rules are all inpublic
.