简体   繁体   中英

Openshift and external mysql db with node-mysql ( Error: connect ECONNREFUSED )

I'm using node js app with external mysql database. It work properly from localhost and other hosting but on openshift I've got this error Error: connect ECONNREFUSED.

        var mysql = require('mysql');
        var dbConfig =  {
            host : 'external.mysql.com',
            port : '3306',
            user : 'user',
            password : 'pass',
            database : 'test'
        };

        var connection = mysql.createConnection(dbConfig);
        connection.connect();
        connection.query('SELECT * FROM test ', function(err, rows, fields) {
                    if (err) throw err;
        });
        connection.end();

I'm also tried telnet external.mysql.com 3306 from openshift and it tell telnet: connect to address 12.34.56.78: Connection refused

Maybe there is some additional params for external connection in openshift

You should make port forwarding to connect remotely services on openshift platform.

Here is the official tutorial and video .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM