0

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.

4
  • After you made the changes in both firewalld and postgresql, did you restart each service? Does the client that you're trying to connect from actually have the ip address of 50.236.122.225? Also, in pg_hba.conf, instead of MYPUBLICIP/24, use 0.0.0.0/0` under remote connections. Jun 28, 2018 at 2:06
  • Also look into tcpdump output and check if there are any traffic on port 5432. Jun 28, 2018 at 11:14
  • @NasirRiley - I tried restarting each after every change. Firewalld will not start up anymore, not sure how I broke it. It now shows the eth0 interface on 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 out
    – deflator
    Jun 28, 2018 at 17:20
  • @deflator Your rule is in the trusted zone and not in the public zone. Be sure that your interface and rules are all in public. Jun 28, 2018 at 17:25

0

You must log in to answer this question.

Browse other questions tagged .