I have a node js app with express which is deployed on openshift. I have created databases via phpmyadmin 4.0 cartridge. I am able to connect to the database but when I make any query it throws error ECONNREFUSED.
I got this error as a response on my browser which is as follows,
{"status":false,"error":{"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect","fatal":true}}
the code for my app is like this,
       var connection =  mysql.createConnection({
         host     : process.env.OPENSHIFT_MYSQL_DB_HOST,
         user     : process.env.OPENSHIFT_MYSQL_DB_USERNAME,
         password : process.env.OPENSHIFT_MYSQL_DB_PASSWORD,
         database : process.env.OPENSHIFT_GEAR_NAME
  });
    connection.connect();
    console.log("connected to login database");
    var strQuery="insert into login values('"+req.body.uname+"','"+req.body.password+"','"+req.body.name+"','"+req.body.mobile+"');";
     connection.query( strQuery, function(err){
    if(err) {
        res.json({
                 "status":false,
                 "error":err
                });
        res.end();
    }else{
        res.json({"status":true });
        res.end();
    }
  });
 connection.end();
I found an answer here connect ECONNREFUSED - node js , sql
but I can only access my database through phpmyadmin 4.0, How do I solve this ?