ahmadnassri / action-google-cloud-sql-proxy

MIT License
8 stars 10 forks source link

Error when trying to connect #51

Open naorye opened 2 years ago

naorye commented 2 years ago

This is my action and it doesn't work. Getting:

Run psql "host=127.0.0.1 port=5432 sslmode=disable dbname=testdb user=postgres"
psql: error: connection to server at "127.0.0.1", port 5432 failed: server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
Error: Process completed with exit code 2.

What am I missing?

name: proxy-test

on:
  workflow_dispatch:

jobs:
  scheduled-job:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions/setup-node@v2
        with:
          node-version: "16"

      - uses: ahmadnassri/action-google-cloud-sql-proxy@v1
        with:
          key: ${{ secrets.GCP_CREDENTIALS }}
          connection: myproj-1234:europe-west1:instance_name
          port: 5432

      - name: Install postgresql-client
        run: sudo apt-get install -y postgresql-client

      - run: psql "host=127.0.0.1 port=5432 sslmode=disable dbname=testdb user=postgres"
ahmadnassri commented 2 years ago

what are the log output of the ahmadnassri/action-google-cloud-sql-proxy@v1 step?

naorye commented 2 years ago

This is the log:

image

BTW, do I have to have public ip for the cloud sql instance?

ahmadnassri commented 2 years ago

I've seen an issue with GitHub actions where port 5432 is in use sometimes even if the proxy was able to attach to it (as per the log), we worked around it by changing the port settings on this action to 5430 and using that going forward...

give that a try.

also, no need to have a public IP

naorye commented 2 years ago

Thanks. Will check and report back.

GusPrice commented 1 year ago

@naorye I'm experiencing a similar issue, but switching the port didn't seem to resolve it for me. Did you have any luck with this?

naorye commented 1 year ago

@GusPrice Yes. You should enable public IP. If I remember correctly, this what solves the issue.

tracy-ash commented 1 year ago

I cannot get it to connect, either

GusPrice commented 1 year ago

ended up switching the base image to a much newer version of sql proxy which is actually off a different image name: gcr.io/cloud-sql-connectors/cloud-sql-proxy. This made the biggest difference for me