Sqlstate[Hy000] [2002] a Connection Attempt Failed.. - When Attempting to Connect from Local to Remote Server

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:

  1. Try removing SSL from 'options'=>['mode'=>'ssl'].
  2. 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.
  3. 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



Leave a reply



Submit