vendredi 8 mai 2015

OpenShift: MySQL PDO 'connection refused', works locally

I have an API i want to deploy to OpenShift, everything works locally, but when trying to use it online i get some problems. When trying to connect to the database, using PDO, i get this error:

Failed to connect to the database: SQLSTATE[HY000] [2002] Connection refused

i have the database set up correctly, and i have the correct details for the connection (im pretty sure). heres some code:

$username = "myuser"; 
$password = "lmnop"; 
$host = "127.0.0.1"; 
$dbname = "loginapi"; 
$port = "3306";

$db = new PDO("mysql:host={$host};port={$port};dbname={$dbname};charset=utf8", $username, $password, $options);

what could be wrong that OpenShift is not allowing the connection? considering that this works on my local machine?

thanks!

Aucun commentaire:

Enregistrer un commentaire