SQLSTATE[HY000] [2002] A connection attempt failed.. - When attempting to connect from Local to remote server
Hardly a surprise. The mysql socket is rarely if ever left open for connections from the public facing interface. usually mysql port (3306) can only be accessed from the private network interface.
Even if the socket was open, there are so many things that that go wrong including firewalls getting in the way and simple timeouts.
Connection Attempt Failed, Connected Party didn't Properly Respond
Solutions:
- Try removing
SSL
from'options'=>['mode'=>'ssl']
. - Disable firewall on the remote database(if you have the access) temporarily just to test. If it works then allow or add source http://localhost on your remote server.
- Use VM or docker, configure SSL on one of these.
AWS RDS and PDO don't work SQLSTATE[HY000] [2002]
Check your security groups:
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.RDSSecurityGroups.html
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithSecurityGroups.html
I suspect the port you are sending DB traffic to on the RDS side isn't open for incoming or outgoing. Or, the port isn't open for incoming or outgoing on your web server, though, I imagine the outgoing ones are open to all.
For example, if using the default port of 3306, then you need to make sure both the RDS security groups and your web server security group ports are open for 3306.
Taken from the post shown as the duplicate:
1) Log into you AWS Console and go to 'EC2'
2) On the left hand menu under 'Network & Security' go to 'Security Groups'
3) Check the Security Group in question
4) Click on 'Inbound tab'
5) Choose 'MYSQL' from drop down list and click 'Add Rule'
If you need any more help feel free to let me know.
Related Topics
Integrating Mailjet API V3 Wrapper as Codeigniter Library
Unit Testing and Static Methods
PHP - How to Build Tree Structure List
Algorithms for String Similarities (Better Than Levenshtein, and Similar_Text)? PHP, Js
How to Keep JSON_Encode() from Dropping Strings with Invalid Characters
Aws Cloudfront + Load Balancer, Url Changes from Main Domain to Load Balancer Subdomain
Get MySQL Query Results as Their Native Data Type
Echo Menu Tree with Recursive Function
Like Query Using Multiple Keywords from Search Field Using Pdo Prepared Statement
PHP APIs for Hotmail, Gmail and Yahoo
How to Declare a Two Dimensional Array
How to Hide the Actual Download Folder Location
Mysql: Add Sequence Column Based on Another Field
Laravel 5 - After Login Redirect Back to Previous Page
Delete First 3 Characters and Last 3 Characters from String PHP