Question

So I've got my Amazon RDS instance, I've allowed my EC2 group to let everything connect, and can make a PDO connection perfectly fine when the script is running from my own machine (using an XAMPP install)

However, as soon as I'm running from my server, I get a

SQLSTATE[HY000] [2005] Unknown MySQL server host

error.

This error does NOT occur when running the scripts from my own machine, where I can connect to the database fine, make inserts and selects, etc. but as soon as I'm on my actual EC2 server, blip, always fails to connect. Furthermore, it fails to connect to ANY MySQL instance. The Amazon RDS documentation offers, as far as I can tell, no help on this.

Further details;

  • I'm connecting with a hostname, not a direct IP

Anyone had any experience with this? Much appreciated.

Was it helpful?

Solution

For Google's sake, found out what was happening - it was simply my webhost denying outbound connections from the shared hosting. Doh! Double check with your webhost to ensure they're not doing sneaky things, people!

As a side note, I did finally get a connection working from a server on Amazon's own EC2 platform - however, the database connection string to PDO would NOT work with the port number on the end of the string.

So, if you're still getting errors, it's possible that Amazon's just telling you the wrong end point, and that you don't need to specify the host. All working now!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top