Getting 500 error on Laravel MySQL application hosted on Google Cloud Platform

357 Views Asked by At

I have a Laravel application using MySQL hosted on Google Cloud Platform (GCP). I am successfully able to build and deploy on Google Cloud platform. I am getting 500 server error when I visit the site url. I have also created a MySQL instance and imported the SQL file. Here is my .env file.

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:+ly4U3QbWcULnj0A31g41q7Yim/L0W5olgwPbsuD1/A=
APP_DEBUG=false
APP_URL=http://127.0.0.1:8080

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=tabiboba
DB_USERNAME=root
DB_PASSWORD=root

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

I dont know why am I getting 500 error. I assumed it has to do something with the database connectivity, so when I go to google cloud shell, I get Access denied for user 'root'@'35.204.189.236' (using password: YES)

enter image description here

Please let me know what am I missing here :(

1

There are 1 best solutions below

0
Vaidehi Jamankar On

The initial error you mentioned is for access related issue which could occur due to a variety of reasons:

  • Connecting to wrong host : Try to connecting the host directly and confirm right host
  • User does not exist : Create a new user and try connecting
  • User exists but client host does not have permission to connect:Grant permission and then try to connect using this.
  • Password is incorrect,or some character issue during password entry: Try with a well known password and check for any character issue while password is taken

You should also check if trying to access the server from a host that is different from the defined host name.Make sure that the IP address you are connecting to and from is authorized to the Cloud SQL instance, refer the documentation for information on authorizing connections

Also check Google Cloud SQL database permissions and verify that your MySQL login has been "granted" permission to login.Go to the Google Cloud SQL console>Go to the Users tab>Select your user name>Verify that the host is your public IP address or optionally use % to mean any host. You can use the Cloud SQL Proxy to access Cloud SQL. This is secure and you do not need IP addresses for Cloud SQL.

Also check out these links for similar issue: