1

I have followed this tutorial and created a database under the name zoho_portal. My app.yaml contents are:

runtime: php
env: flex

runtime_config:
  document_root: public

# required on some platforms so ".env" is not skipped
skip_files: false

    env_variables:
      # The values here will override those in ".env". This is useful for
      # production-specific configuration. However, feel free to set these
      # values in ".env" instead if you prefer.
      APP_LOG: errorlog
      STORAGE_DIR: /tmp
      CACHE_DRIVER: database
      SESSION_DRIVER: database
      ## Set these environment variables according to your CloudSQL configuration.
      DB_HOST: localhost
      DB_DATABASE: zoho_portal
      DB_USERNAME: USER
      DB_PASSWORD: PASS
      DB_SOCKET: /cloudsql/zoho-portal-159018:us-central1:zoho-portal 

    beta_settings:
        cloud_sql_instances: "zoho-portal-159018:us-central1:zoho-portal"

I have also added this to my composer.json:

"post-deploy-cmd": [
    "chmod -R 755 bootstrap\/cache"
]

However, after deploying this using gcloud app deploy, and visiting the website at: https://zoho-portal-159018.appspot.com/, I receive this error:

SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from sessions where id = iq8isoeEqTaj5xVNmVm0JuFKtR8vtSEB0ajJl23o limit 1)

As far as I can see, I haven't missed any step listed in the tutorial and the database is set up correctly. Could this have something to do with database migration?

Adeel Ahmad
  • 121
  • 4
  • Visiting your website seems you're receiving SQLSTATE[HY000] [2002] Connection refused error. Please check out this [answer](https://stackoverflow.com/questions/20615433/app-engine-fails-to-connect-to-google-cloud-sql?answertab=votes#tab-top) to see if it helps. – Kamran Jun 03 '17 at 20:18
  • I have added `DB_HOST: localhost` in my `app.yaml` file and now I get the `No such file or directory` error, the one with which I have been stuck with for a few weeks. Could you please check and tell what I might be doing wrong? – Adeel Ahmad Jun 04 '17 at 05:44
  • @AdeelAhmad were you able to resolve the issue? If so it is recommended to post the solution here to better help the community. If not, it is recommended to try the solutions described in the [Google Groups thread here](https://groups.google.com/forum/#!msg/google-appengine/IZgep9t3LbI/0AZprAoBBgAJ), along with the reported issue on the [Google PHP Samples Git repository](https://github.com/GoogleCloudPlatform/php-docs-samples/issues/371). – Jordan Sep 14 '17 at 19:10

2 Answers2

3

Your settings are right, so you may have forgotten to enable the Cloud SQL Administration API, as it is indicated below "Before you begin" in the documentation page.

  • I just enabled it (however, I think it was enabled before), but I still get the same `No such file or directory` error. Are you certain this isn't a migration issue? – Adeel Ahmad May 30 '17 at 02:42
  • The "no such file or directory" error means that the socket file does not exist. In the case of a migration related error it would say something like "schema X not found". Try to connect to the instance via SSH and check what's inside the directory `/cloudsql`. You can also try to remove the `DB_HOST` environment variable, as it is not necessary. – Víctor Díaz May 30 '17 at 19:14
  • When I remove the `DB_HOST` environment variable, I get a `Connection refused` error message. Also, where can I find the IP address to establish an SSH connection? I tried the IPv4 address listed in Cloud SQL section, but it always times out. – Adeel Ahmad Jun 01 '17 at 04:16
0

I also had the same issue but adding DB_CONNECTION: mysql to the env_variables in my app.yaml did the trick for me.

Norris Oduro
  • 101
  • 1