I'm using Golang (github.com/jackc/pgx/v4) to try and connect to my compute engine VM instance, but not having any luck, "Unable to connect to database: failed to connect to host=[IP] user=postgres database=postgres: dial error (dial tcp 127.0.0.1:5433: connectex: No connection could be made because the target machine actively refused it.)"
after following the postgres install on GCP: https://cloud.google.com/community/tutorials/setting-up-postgres
In golang I'm using pgx.Connect()
and this is the DSN I'm passing: dsn = "pgsql:host=[My external VM IP on GCP];port=5432;dbname=[DB name];user=postgres;password=[my pass]"
I have a funny feeling I need to connect to an instance ID, but there's no documentation on what's the correct host I pass or the right DSN format when trying to access a VM on GCP.