1

I can't get remote access to my PostgreSQL server in Ubuntu16.04 VM instance in google cloud from my laptop. I've added my laptop IP to pg_hba.conf in Google Cloud and tried both "md5" and "Trust" methods:

#IPv4 local connections: host all all 127.0.0.1/32 md5 host all all [mylocalIP]/32 md5

Furthermore I've tried both * and [mylocalIP] in postgresql.conf:

# - Connection Settings 
listen_addresses = '*'      # what IP address(es) to listen on;

In google cloud firewall i've following setup

default-allow-http  http-server     IP ranges: 0.0.0.0/0    tcp:80  Allow   1000    default
default-allow-https https-server    IP ranges: 0.0.0.0/0    tcp:443 Allow   1000    default
default-allow-psql  Apply to all    IP ranges: 0.0.0.0/0    tcp:5432Allow   1000    default
Laptop              Apply to all    IP ranges: [mylocalIP]/32   all     Allow   1000    default

Also I can putty to my Google Cloud VM instance with SSH key, so I can have some remote connection.

I think this is Google Cloud firewall issue cause I can use remote connection to my postgreSQL server in my local VM (win 2012 server) with following setup without problems.

Thanks in advance!

Vadim
  • 4,996
  • 1
  • 26
  • 30

1 Answers1

0

In your pg_hba.conf file, try adding the line

host    all             all           0.0.0.0/0         md5

Your firewall rules appear to be correct. You only need the rule tcp:5432 for ip ranges 0.0.0.0/0

Aypak
  • 1
  • 2
  • "try adding the line" - why is this line added? – baxx May 14 '23 at 16:27
  • 1
    This line means allow all users to connect to all databases from any IP address, and they must provide an MD5-encrypted password for authentication. – Aypak May 15 '23 at 18:41