Can you print this variable IP_address
? Does it match the IP of your database host?
What if, instead of retrieving the IP of the hostname, you just put the IP directly into the code, like in this sample?
If it doesn’t work, make sure you can connect to your db host using telnet: telnet DB_IP 3306
, where DB_IP is the IP of your database host.