1
votes

I already have a working laravel project with database in my local host. But when i use GCP app engine i follow the step with database connection. I already create mysql database in my cloud and imported all my sql from working local database. When i app deploy the shows SQLSTATE[HY000] [2002] No such file or directory below are my app.yaml file content

runtime: php
env: flex

runtime_config:
  document_root: public

# Ensure we skip ".env", which is only for local development
skip_files:
  - .env

env_variables:
  # Put production environment variables here.
  APP_LOG: errorlog
  APP_KEY: <app-key>
  CACHE_DRIVER: database
  SESSION_DRIVER: database
  ## Set these environment variables according to your CloudSQL configuration.
  DB_HOST: <db_host>
  DB_DATABASE: info
  DB_USERNAME: root
  DB_PASSWORD: <db_pass>
  DB_SOCKET: "/cloudsql/lkcfes:asia-east1:lkcfes"

beta_settings:
    # for Cloud SQL, set this value to the Cloud SQL connection name,
    # e.g. "project:region:cloudsql-instance"
    cloud_sql_instances: "lkcfes:asia-east1:lkcfes"
2

2 Answers

0
votes

Can you try removing the DB_SOCKET environment variable? The error you are getting is because that socket does not exist.

You should not specify both a DB_HOST and DB_SOCKET, just either of them.

0
votes

According to your configuration, and the last comment, you are not reaching the instance due a network error. I think you should review your firewall configuration in GCP console and the "authorized networks" in the instance configuration.

You can find more info here https://cloud.google.com/sql/docs/mysql/diagnose-issues