SOLVED: Laravel: connection to AWS RDS results in a timed out

1

I was trying to migrate the database to AWS RDS through Laravel using php artisan migrate, however, it gave me this error:

Illuminate\Database\QueryException  : SQLSTATE[08006] [7] could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host "xxxxxxxxx.xxxxxxxxx.us-east-2.rds.amazonaws.com" (xx.xxx.xxx.xxx) and accepting
TCP/IP connections on port 5432? (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations)

I have done some researches on this issue, what I found is I need to create a new security group to allow the access from my IP address, and I have added a new rule with the Type of "PostgreSQL" and its default settings but my IP in the "Source" column. And I am still not able to migrate my database (giving me the same error as above)

This is the database config in the .env file, maybe some fields are wrong?

DB_CONNECTION=pgsql
DB_HOST=xxxxxxxxx.xxxxxxxxx.us-east-2.rds.amazonaws.com
DB_PORT=5432
DB_DATABASE=xxxx
DB_USERNAME=xxxx
DB_PASSWORD=xxxx

I would be appreciated for any helps!

php
database
laravel
postgresql
amazon-web-services
asked on Stack Overflow Apr 10, 2019 by Cheng Chen • edited Nov 28, 2019 by Cheng Chen

1 Answer

0

Have you checked if the server has access to RDS?

ssh into your server, then run

psql -h xxxxxxxxx.xxxxxxxxx.us-east-2.rds.amazonaws.com -d mydb -U myuser
answered on Stack Overflow May 30, 2019 by Oli Girling

User contributions licensed under CC BY-SA 3.0