I have created laravel application with database it run on localhost so i decide to deploy on GCP appengine but when i click on deploy this happen
SQLSTATE[HY000] [2002] Connection timed out
i connecting to my GCP sql Instance below are my app.yaml
1st i use local host that uses sql_proxy it show no files directory then i remove the DB_Socket then this error come out SQLSTATE[HY000] [2002] Connection timed out
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: base64:G9druqluKMZ6TugSgmM1OJVwWSzfstc08acMRBAqxwg=
CACHE_DRIVER: database
SESSION_DRIVER: database
## Set these environment variables according to your CloudSQL configuration.
DB_HOST: 35.231.242.40
DB_DATABASE: lkcfes
DB_USERNAME: root
DB_PASSWORD:
This question is more appropriate for a support case so that a Google Cloud Platform support agent can inspect your app.yaml and Cloud SQL instance.
Having said that, there is a guide here on running Laravel on GAE Flex. You'll find it includes using a "beta_settings" section on your yaml, the Cloud SQL instance's public IP is not used.
Related
I added in ENV file on Heroku informations from Awardspace, because I want to connect that database with Laravel project deployed on Heroku.
I am getting error SQLSTATE[HY000] [2002] Connection refused
you have these credentials you should put it in settings -> config vars->
DATABASE_URL
DB_CONNECTION=pgsql
DB_DATABASE
DB_HOST
DB_PASSWORD
DB_PORT
DB_USERNAME
after added these credentials with database
you should run in bash php artisan migrate
and work fine
hopefully that is help you
use this command for clear cache.
php artisan optimize:clear
php artisan optimize
I am using laravel 6 and I want to deploy laravel based websocket server using supervisor on google cloud Flex app engine platform.
I am using this package: beyondcode/laravel-websockets
I have setup everything and everything is working fine on local machine! What is the exact procedure to follow to deploy it on GCP?
My additional-supervisord.conf
[program:websockets]
command = php %(ENV_APP_DIR)s/artisan websockets:serve
enviroment = PORT="6001"
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes=0
user = root
autostart = true
autorestart = true
priority = 10
stopwaitsecs = 20
App.yaml
runtime: php
env: flex
runtime_config:
document_root: public
service: orders
skip_files:
- .env
#only for testing purpose.
manual_scaling:
instances: 1
env_variables:
APP_NAME: "Havn"
BROADCAST_DRIVER: pusher
PUSHER_APP_ID: SOMEID
PUSHER_APP_KEY: SOMEKEY
PUSHER_APP_SECRET: SOMESECRET
PUSHER_APP_CLUSTER: mt1
LARAVEL_WEBSOCKETS_PORT: 6001
PUSHER_SCHEME: https
PUSHER_HOST: 127.0.0.1
PUSHER_PORT: 6001
QUEUE_DRIVER: database
beta_settings:
cloud_sql_instances: "INSTANCE ID"
You can find in the official documentation how to use WebSockets to create a persistent connection from a client (such as a mobile device or a computer) to an App Engine instance.
Please consider that WebSockets connection will time out after one hour.
Creating Persistent Connections with WebSockets PHP
I am deploying a new application to Google App Engine Flex environment. The app is powered by Laravel.
I am able to connect to the database on my local machine, however, I am unable to connect to the database once I deploy my application.
What information do I need to include in the app.yaml file to connect to the database? Do I require any other information in a different file?
"message": "SQLSTATE[08006] [7] could not connect to server: Connection refused\n\tIs the server running on host \"localhost\" (::1) and accepting\n\tTCP/IP connections on port 5432?\ncould not connect to server: Connection refused\n\tIs the server running on host \"localhost\" (127.0.0.1) and accepting\n\tTCP/IP connections on port 5432? (SQL: select * from \"users\" where \"email\" = mitchell#efficialtec.com and \"users\".\"deleted_at\" is null limit 1)",
This is the contents of my .ENV file which allows me to connect locally
APP_ENV=development
APP_KEY=base64:B0G3Yr82fWO7xw8LrvcOC19DGUAEd32loJlPHCfP2sg=
APP_DEBUG=true
LOG_CHANNEL=stack
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_POST=5432
DB_DATABASE=DATABASE
DB_USERNAME=USERNAME
DB_PASSWORD=PASSWORD
DB_SOCKET: "/cloudsql/CONNECTION_NAME"
This is the contents of my app.yaml file:
env: flex # let app engine know we use flexible environment
service: SERVICENAME
automatic_scaling:
min_num_instances: 1
max_num_instances: 2
cpu_utilization:
target_utilization: 0.8
runtime_config:
document_root: public
skip_files:
- .env #we want to skip this to make sure we don’t mess stuff up on the server
env_variables:
# Put production environment variables here.
APP_ENV: development
APP_DEBUG : true # or false
APP_KEY: base64:B0G3Yr82fWO7xw8LrvcOC19DGUAEd32loJlPHCfP2sg=
APP_LOG: daily
APP_TIMEZONE: UTC #your timezone of choice
# Replace USER, PASSWORD, DATABASE, and CONNECTION_NAME with the
# values obtained when configuring your Cloud SQL instance.
POSTGRES_USER: USERNAME
POSTGRES_PASSWORD: PASSWORD
POSTGRES_DSN: pgsql:dbname=bnsw;host=/cloudsql/CONNECTION_NAME"
DB_HOST: localhost
DB_DATABASE: DATABASE
DB_USERNAME: USERNAME
DB_PASSWORD: PASSWORD
DB_SOCKET: "/cloudsql/CONNECTION_NAME"
beta_settings:
cloud_sql_instances: "CONNECTION_NAME"
Any help on this would be greatly appreciated, I have been looking on Google for almost a week with no answers yet!
By default, Laravel does not have DB_SOCKET under pgsql connection.
Thus, in order to connect to cloud SQL connection from app engine, you env show look like :
DB_CONNECTION=pgsql
DB_HOST=/cloudsql/CONNECTION_NAME
DB_DATABASE=DATABASE
DB_USERNAME=USERNAME
DB_PASSWORD=PASSWORD
Also please, don't include DB_PORT in the database env variables.
I followed this Gitlab tutorial to test and deploy Laravel applications with GitLab CI/CD and Envoy.
All works well, but when I run a pipeline it shows this error:
PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'user'#'172.17.0.4' (using password: YES)")
My IP server is 172.0.0.1 but the pipeline set the IP by 172.17.0.4.
How can I set the IP to make work it?
Finally, it works. I added only this values to the yml file:
variables:
MYSQL_DATABASE: mydatabase
MYSQL_ROOT_PASSWORD: 123456
Obviously the same values to the .env file.
(I also uninstalled and re-installed MySQL, but I don't know if that helped to solve it)
I am trying to deploy my Dropwizard project to Heroku.
I have added a Procfile and a Postgres DB to the Heroku app.
My Procfile reads:
web: java $JAVA_OPTS -Ddw.server.connector.port=$PORT -Ddw.database.url=$DATABASE_URL -jar target/api-1.0-SNAPSHOT.jar server config.yml
When I try to deploy I receive the following error/crash message in the logs.
org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator: HHH000342: Could not obtain connection to query metadata : Driver:org.postgresql.Driver#53d13cd4 returned null for URL:postgres://fdeqzbddzbefaz:138912590e989b1b8fab5d169a1aea291f04b2d3bc040b1bbf6642a9207a5355#ec2-54-235-101-91.compute-1.amazonaws.com:5432/d67crr4pvqrfee
Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
State changed from starting to crashed
Process exited with status 1
My config.yml reads
database:
# the name of your JDBC driver
driverClass: org.postgresql.Driver
# the username
user: localusername
# the JDBC URL
url: jdbc:postgresql://localhost/dbname
# use the simple server factory if you only want to run on a single port
# HEROKU NOTE - the port gets be overridden with the Heroku $PORT in the Procfile
server:
type: simple
applicationContextPath: /
#adminContextPath: /admin # If you plan to use an admin path, you'll need to also use non-root app path
connector:
type: http
port: 8080
Does anyone have any trouble shooting ideas?
The DATABASE_URL env var is not directly compatible with the JDBC URL format. See docs. Specifically,
The DATABASE_URL for the Heroku Postgres add-on follows the below convention
postgres://username:password#host:port/dbname
However the Postgres JDBC driver uses the following convention:
jdbc:postgresql://host:port/dbname?user=username&password=password
Instead, try using JDBC_DATABASE_URL as documented here