简体   繁体   中英

Lavavel migrate not work in a LAMP AWS instance with MySQL RDS DB --> SQLSTATE[HY000] [2002] Connection timed out

I have setup an EC2 aws instance with Apache, PHP 7.2, Git, Composer and a RDS MySQL 5.7 database.

I followed the AWS official tutorials and others like Deploying and Scaling a Laravel Web App on AWS — Part 1 but I can't finish the laravel project installation. Using ssh terminal connection, in time to migrate (sudo php artisan migrate), I get the response:

Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] Connection timed out (SQL: select * from information_schema.tables where table_schema = database_name and table_name = migrations)

When I try this same connection using MySQL WorkBench, I can connect, create or drop a table for example.

I think the.env file or config/database.php are properly set, but I can't explain why I get this error. Any help please? Thanks

Seeing as this is a connection issue:

  • Between your EC2 instance and the RDS MySQL database: you may have to add a rule to your security group allowing the standard MySQL port. If you've made changes to the Network Access Control List attached to the subnet that your EC2 instance is in, you'll also want to modify the NACL to allow inbound AND outbound traffic from the instance to the RDS database.

  • Between your RDS instance and Workbench: Check the security group on the Database (not the EC2 instance's security group)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM