GoogleCloudPlatform / cloud-sql-proxy

A utility for connecting securely to your Cloud SQL instances
Apache License 2.0
1.28k stars 350 forks source link

Getting this Error while trying to connect to sql-cloud-proxy "Is the server running on that host and accepting TCP/IP connections?" #2334

Open Umer-TMSF opened 4 days ago

Umer-TMSF commented 4 days ago

Question

Hi, I am facing this particular issue below while trying to connect to cloud-sql-proxy.

 psql: error: connection to server at "127.0.0.1", port 5433 failed: Connection refused
    Is the server running on that host and accepting TCP/IP connections? 

I am running following steps

      # Step : Run Cloud SQL Proxy
      - name: Enable cloud SQL proxy to temp instance
        run: |
            curl -o cloud-sql-proxy https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.7.0/cloud-sql-proxy.linux.amd64
            chmod +x cloud-sql-proxy
            ./cloud-sql-proxy --port 5432 ${{ steps.secrets.outputs.POSTGRES_CONNECTION_NAME }}  --credentials-file google-creds.json > cloud-sql-proxy.out 2> cloud-sql-proxy.err < /dev/null &
            echo $!
            echo CLOUD_SQL_PROXY_PID=$(echo $!) >> $GITHUB_ENV
            sleep 5

and try to connect with pg-client using below command

PGPASSWORD=${{password}} psql -h 127.0.0.1 -p 5432 -U postgres -c 'SELECT NOW()'

I tried to change the port as well to see if port is already being used but still now luck.

Code

No response

Additional Details

No response

jackwotherspoon commented 4 days ago

Thanks for raising this @Umer-TMSF 😄

The Cloud SQL Proxy normally outputs logs.

The sample you are using swallows the logs which is probably hiding the true cause of the error. Let me try and come up with a nice way from Github actions to output the Proxy logs.