I am trying to connect to amazon RDS MySQL from Heroku using CodeIgniter PHP framework version 3. I followed all the steps listed in Heroku documentation about Amazon RDS but can't figure out what I am doing wrong?
Here are my CodeIgniter database settings:
$db['rds'] = array(
'dsn' => '',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE,
'port' => 3306,
'encrypt' => [
'ssl_ca' => APPPATH."../.config/rds-combined-ca-bundle.pem",
'ssl_verify' => TRUE
]
);
$db['rds']['hostname'] = getenv('RDS_DATABASE_HOSTNAME');
$db['rds']['username'] = getenv('RDS_DATABASE_USERNAME');
$db['rds']['password'] = getenv('RDS_DATABASE_PASSWORD');
$db['rds']['database'] = getenv('RDS_DATABASE_DBNAME');
But I keep getting this error:
mysqli::real_connect(): (HY000/2002): Connection timed out /app/vendor/codeigniter/framework/system/database/drivers/mysqli/mysqli_driver.php 201
Here is what I checked:
- I checked in RDS security groups and CIDR/IP - Outbound 0.0.0.0/0 is there
- I added a separate MySQL user with GRANT privileges SELECT,UPDATE,INSERT,DELETE and REQUIRE SSL
- Added the combined certificate file to project root directory
.config/rds-combined-ca-bundle.pem
and deployed on Heroku - On local machine the same code works fine
- Tried restarting the RDS instance
Where else should I look if some setting is wrong?