简体   繁体   中英

how to connect to psql on google VM Instance

I can connect and ssh into the external VM. But I have a hard time accessing the postgres serve on the VM. I have done the following

  1. I updated the postgresql.conf to

    listen_addresses = '*'

    port = 5432

    1. I have did the following to my firewall.

在此处输入图片说明

what should i do next?

The firewall rule is really insecure (you are allowing everyone on internet to connect to your GCE instance using all the ports) and maybe another firewall rule is blocking this rule due to the priority is really low (the greater the priority number is, the lower priority has). Did you follow this tutorial? once you add listen_addresses = '*' , you need to restart your PostgreSQL service with sudo service postgresql restart .

Also, you need to create 2 firewall rules, one for ingress and another one for egress. Both to accept traffic to tcp:5432 , can you please create 2 firewall rules with more priority that accepts traffic from that port with a smaller IP range?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM