AWS CodeBuild fails to interact with RDS instance - php

I have the most basic setup in AWS:
a publicly accessible RDS instance (PostgreSQL 9.6.6 - same as my development one)
a CodeBuild project
both in the default VPC.
My application is written in Laravel 5.5 and the buildspec.yml runs ./artisan migrate --force at some point and CodeBuild outputs the following error:
[Container] 2018/03/10 19:41:36 Running command php artisan migrate --force
[Illuminate\Database\QueryException]
SQLSTATE[08006] [7] timeout expired (SQL: select * from information_schema.
tables where table_schema = public and table_name = migrations)
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[08006] [7] timeout expired
[PDOException]
SQLSTATE[08006] [7] timeout expired
Where should I start looking for an error?

You need to make sure that the RDS security group allows inbound traffic from Code Build.
Go to https://ip-ranges.amazonaws.com/ip-ranges.json
Search for CODEBUILD and choose your region.
Add the IP to the inbound rule in the RDS Security Groups.

Create a Security Group for Code Build and reference it as a source from the DBSecurity Group.

Related

Laravel / Postgre SQLSTATE[08006] [7] timeout expired (SQL: select * from "document")

In my local laravel environment I don't have any problems connecting.
But in production I'm getting this:
return "SQLSTATE[08006] [7] timeout expired (SQL: select * from "document")" in all routes that queries the bank..
DB_CONNECTION=pgsql
DB_HOST=**.**.**.**
DB_PORT=5432
DB_DATABASE=***********
DB_USERNAME=************
DB_PASSWORD=***************
Problem was in the cache, noticed the password change for an incorrect one and I clicked the new one again and gave p
php artisan config:cache
started working again

What's wrong with query error in Laravel with XAMPP on Mac?

I am a beginner programmer and use Laravel with XAMPP on Mac. And all my attempts to create migrations lead to Query Error:
Illuminate\Database\QueryException
SQLSTATE[HY000] [2006] MySQL server has gone away (SQL: select * from information_schema.tables where table_schema = laravel-app and table_name = migrations and table_type = 'BASE TABLE')
My PHP version is 7.3.29 on MacBook
In XAMPP web-server: Apache/2.4.48 (Unix) OpenSSL/1.1.1k PHP/8.0.10 mod_perl/2.0.11 Perl/v5.32.1
What steps should i take to customize the request?
This is not a Laravel issue, but a general MySQL Issue. Maybe the server is not running. Are you sure you're running MySQL in the background?
Check this link: MySQL Gone Away
Do the following checks in your system:
The Database Engine is running
You have created your database
You have created an user and granted permissions to the database
You have setup the user and the database in your Laravel's .env file.
After this, try to run the migrations command again, which is:
php artisan migrate
As explained Here

Laravel using vagrant: php artisan migrate --seed giving errors [duplicate]

This question already has answers here:
MySQL connection not working: 2002 No such file or directory
(23 answers)
Mysql localhost != 127.0.0.1?
(4 answers)
Closed 2 years ago.
homestead version: 9.2.0
vagrant version: 2.2.7
php version: 7.2.21
mysql version: 8.0.18
I created a new laravel project. I created a database called tickets. I've added the third party code from https://github.com/creativetimofficial/material-dashboard-laravel. When I get to step where you run "php artisan migrate --seed" I'm getting two different errors depedning on how I set db port in .env file.
Here's a picture of my db users and their hosts.
when DB_HOST=127.0.0.1 and I run the artisan migrate I get an error saying Connection refused. I only tried using 127.0.0.1 because I saw online people saying to use this instead of localhost. Since the connection is refused I have a feeling this isn't correct.
When DB_HOST=localhost and I run artisan migrate I get an error saying
No such file or directory (SQL: select * from information_schema.tables where table_schema = tickets and table_name = migrations and table_type = 'BASE TABLE') {"exception":"[object] (Illuminate\\Database\\QueryException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = tickets and table_name = migrations and table_type = 'BASE TABLE') at /Applications/MAMP/htdocs/ticket-dashboard/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669)
Questions:
1) should I be using the IP instead of localhost and if so why do I get connection refused with using the IP?
2) If using localhost is fine, what needs to be fixed to bypass this error?
I've been testing everything I can find online to help, but this is the closest I've gotten. Any advice or ideas would be greatly appreciated

Laravel Migration Postgres error SQLSTATE[08006]

I want to connect Laravel with Postgresql database
when I run
php artisan migrate
I get this error
SQLSTATE[08006] [7] timeout expired (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations)
my .env
DB_CONNECTION=pgsql
DB_HOST=projects.cggts***.rds.amazonaws.com
DB_PORT=5432
DB_DATABASE=projects
DB_USERNAME=*********
DB_PASSWORD=*********
It'll probably inbound VPC problem on AWS . You have to update IP range for your RDS db. You'll find it under EC2->Network & Security->Security Groups . Have fun ;)

Doctrine - Error with command database:create or schema:update -f

I need to change some calculations in a CRM but when I've receive the zip file I've unzip it in WAMP, it's use Symfony so I've done the install with composer and update. I'm a beginner with Symfony, Doctrine, ... so I've tried to do the next commands and I've receive some error message I don't know how to resolve it, I've research on the web all days and I've found nothing.
The commands
php bin/console doctrine:schema:update -f
or
php bin/console doctrine:database:create
I've these error messages :
[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[08006] [7] FATAL: role "stats_crm" does not exist
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[08006] [7] FATAL: role "stats_crm" does not exist
[PDOException]
SQLSTATE[08006] [7] FATAL: role "stats_crm" does not exist
I don't know what do you need for the informations about my environment, I'm using PhpStorm 2016.3.2, PostgreSQL 9.6, PgAdmin 3, phpPgAdmin 5.1, WAMP 3.0.6 and PHP 5.6.25
Thank you, sorry for my bad English and I don't know if you need more information.
The exception message tells you that doctrine can't login to your database host with username stats_crm, because that role does not exist.
To fix that exception, you have to find the right username that can get you in to the database server. Then, open your app/config/parameters.yml, find node named database_user, and update it accordingly (and database_password if necessary).

Categories