Q: Problem to connect a laravel GC App Engine to GC SQL postgres I try to connect my laravel app (stored on google cloud App Engine) to my postgresql database (stored on google cloud SQL).
This is the error : SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? (Connection: pgsql, SQL: select * from "roles")
I don't found my error, and many solutions founded is for mysql (and don't work in my case).
You find the app.yaml here.
runtime: php81
env: standard

runtime_config:
 document_root: public


handlers:
- url: /(.*\.(gif|png|jpg|css|js))$
  static_files: public/\1
  upload: public/.*\.(gif|png|jpg|css|js)$

- url: /.*
  secure: always
  redirect_http_response_code: 301
  script: auto

beta_settings:
  cloud_sql_instances: app-id:zone:instance=tcp:5432

env_variables:
  APP_DEBUG: true
  APP_ENV: production
  APP_LOG: errorlog
  APP_KEY: my_app_key
  APP_STORAGE: /tmp
  VIEW_COMPILED_PATH: /tmp
  CACHE_DRIVER: file
  SESSION_DRIVER: cookie
  DB_CONNECTION: pgsql
  DB_HOST: localhost
  DB_PORT: 5432
  DB_DATABASE: postgres
  DB_USERNAME: instance
  DB_PASSWORD: password
  DB_SOCKET: /cloudsql/app-id:zone:instance
  LOG_CHANNEL: stderr
  JWT_SECRET: my-jwt-secret

I tried to replace the DB_HOST by 127.0.0.1, public_ip and private_ip, but I have no result :(
Thanks for your help

A: Try the following env variables:
  ## for MYSQL, use DB_SOCKET:
  ## for PostgreSQL, use DB_HOST:
  DB_HOST: "/cloudsql/YOUR_CONNECTION_NAME"

