1

I have a Laravel 5.3 application which I have deployed using Google Application Engine. However, when I query my database, I am faced with the following error:

SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `users` where `email` = test+support@loungeroom.nl limit 1)

My app.yaml file contents are as follows:

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
  MYSQL_DSN: mysql:unix_socket=/cloudsql/zoho-portal-159018:us-central1:zoho-portal;dbname=zoho_portal
  MYSQL_USER: adeel
  MYSQL_PASSWORD: pass

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

I have followed all the steps listed in this tutorial. I have also ensured that my Cloud SQL API is enabled.

Adeel Ahmad
  • 1,033
  • 1
  • 11
  • 24
  • 1
    Try following this specific [Laravel on GAE Flex guide](https://cloud.google.com/community/tutorials/run-laravel-on-appengine-flexible). Also try using quotes '"' around your 'cloud_sql_instances' connection name in your app.yaml as shown in the guide. – Jordan May 09 '17 at 19:11
  • I have followed the guide and updated my app.yaml file according to the instructions. However, I'm getting this error when I visit (https://zoho-portal-159018.appspot.com/): SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `sessions` where `id` = ySejUS01EZ5kRcZQrrFh8RcMdVybiOfVjio9vNW0 limit 1) Could this have something to do with how the database is set up? – Adeel Ahmad May 27 '17 at 05:23
  • Be sure you're running Laravel 5.4.16, as the DB_SOCKET environment variable is not recognized in prior versions. – Brent Shaffer Jun 11 '19 at 23:36

1 Answers1

-2

When using the database session driver, you will need to setup a table to contain the session items. Below is an example Schema declaration for the table:

Schema::create('sessions', function($table)
{
    $table->string('id')->unique();
    $table->text('payload');
    $table->integer('last_activity');
});

You can find further detail on the "Session" documentation page for Laravel.

George
  • 1,488
  • 1
  • 10
  • 13