On AWS why does internal DNS lookup for RDS fail in PHP page?

I have an AWS Elastic Beanstalk configuration (PHP) with one EC2 instance and one RDS instance. It's a QA environment. It was working well but recently it started to fail consistently with the following error (there have been no code changes):

"PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution Error: Error in Connection to pdo_mysql database :Connection attempt failed: SQLSTATEHY000 2002 php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution"

There is nothing temporary about it.

If I substitute the IP address of the RDS instance in place of the host name it works well in AWS.

If I access the AWS RDS instance from my local development machine (outside AWS) using the host name it executes the same code perfectly.

Nslookup for the RDS host name works well from the EC2 instance.

I have stopped and started the ec2 instance and rebooted the RDS instance to no avail.

I see there are sporadic posts about intermittent AWS DNS failures but nothing that seems to fit my problem.

Does anybody recognise the problem? Does anybody know what further tests I can do in an effort to diagnose it?

Thanks

https://forums.aws.amazon.com/thread.jspa?threadID=141277


Solution 1:

It turns out that restarting apache fixed the problem at least until the next time I restarted the ec2 instance. There is obviously some problem with my version of the AMI (built in August 2013). A currently built (Dec 2013) version of Elastic Beanstalk does not have this problem.