Configure Discourse to use a separate PostgreSQL server

So I have a newly installed Discourse instance running via docker in a VM on Google Cloud. I currently have file uploads and discourse backups to buckets on Google Cloud enabled and those functions are working properly after following the instructions on the Configure an S3 compatible object storage provider for uploads thread. I can see the test uploads in the bucket and when I look at upload URLs, all uploads are showing the proper URL from the CDN so they seem like they are pulling correctly from the bucket.

I then created a PostgreSQL 15.2 instance on Google Cloud and did the database setup procedure that’s outlined in the first post and configured the app.yml file as well. The default port for PostgreSQL on Google Cloud is 5432 so I left out those lines.
If I use the public IP address of the postgres instance in the app.yml config, when I rebuild the app, I get the following:

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 1024 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
a6a71b00bce378aa6334ae1c9fe103778d260bb699fe598f9685689e8b5ce450

Just to see what’s going on, I tried using the other IPs of the postgres instance.
If I use the private IP address of the postgres instance, I get the following:

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 1024 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
7333126c522eb51ace4d55ea89803eea54b96704baab70c322008cf2836ba47a

If I use the outgoing IP address of the postgres instance, I get the following:

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 1026 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
c588d2b6977b9e7d493b0b59bc694369cb7c2219de67d5886112ed16312626ae

Using all the different IPs, the failed messages are all very similar and the postgres database does not receive any data or connections at all. Does anyone have any insight on what I’m doing wrong?

Also, is my issue being caused by not using the Cloud SQL Auth Proxy on the VM instance? If it is, I guess I’ll have to build a script to run the proxy and time it before the app rebuild. Does anyone have any insight on that?

Thanks for the time guys.