0

I'm new to AWS and trying to connect using PHP to a test RDS like this

$dbhost = 'xxxx.xxxxxxxxxxx.rds.amazonaws.com';
$dbport = 3306;
$dbname = 'xxxx';
$charset = 'utf8' ;

$dsn = "mysql:host={$dbhost};port={$dbport};dbname={$dbname};charset={$charset}";
$username = 'xxxx';
$password = 'xxxxxx';

try{
    $pdo = new PDO($dsn, $username, $password);
}
catch(exception $e){
    echo "error ".$e->getMessage();
}

But I get this in the log

 [Warning] IP address 'xxx.xx.x.xxx' could not be resolved: Temporary failure in name resolution

[Update] And the page displays error 500 internal server error. The database security group allows connection from anywhere. I'm not using Elastic Beanstalk I just created instances, security policies, target groups, load balancers and need to get the application on the instance working by connecting it to the database.

How to fix this?

  • Is it actually failing to connect?! – Michael Hampton Feb 8 '18 at 20:18
  • yes. error 500 internal server error – PHP User Feb 8 '18 at 20:22
  • 1
    That's only a warning. Look for the actual problem elsewhere. – Michael Hampton Feb 8 '18 at 20:25
  • when i remove the connection code the php file executes without issues. when i keep the code the instance changes to 'unhealthy' – PHP User Feb 8 '18 at 20:28
  • 1
    Again, you need to look elsewhere. Go through your logs. Make sure you are actually seeing the exception that gets thrown. It sounds like your web server is displaying a generic 500 page instead of your exception. – Michael Hampton Feb 8 '18 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.