skip to Main Content

I’m trying to connect a Node.js app with a MySQL database which works for another app really well on a remote server with this code:

var mysql = require('mysql');

var con = mysql.createConnection({
  host: "www.<dnw>.com",
  port: <correct port number>,
  user: "<correct Username>",
  password: "<correct password>",
  database: "<correct databasename>"
});
con.connect(function(err) {
        if (err) 
        {
            throw err;
         }
      });

con.end();

On execution I get this as a error message

/home/akiku/node/dnwbot/main.js:49
            throw err;
            ^

Error: connect ECONNREFUSED 85.25.34.68:3306
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1198:14)
    --------------------
    at Protocol._enqueue (/home/akiku/node/dnwbot/node_modules/mysql/lib/protocol/Protocol.js:145:48)
    at Protocol.handshake (/home/akiku/node/dnwbot/node_modules/mysql/lib/protocol/Protocol.js:52:23)
    at Connection.connect (/home/akiku/node/dnwbot/node_modules/mysql/lib/Connection.js:130:18)
    at Object.<anonymous> (/home/akiku/node/dnwbot/main.js:46:9)
    at promises.push.Promise (/home/akiku/node/dnwbot/node_modules/telebot/lib/telebot.js:439:29)
    at new Promise (<anonymous>)
    at TeleBot.event (/home/akiku/node/dnwbot/node_modules/telebot/lib/telebot.js:432:32)
    at promise.then (/home/akiku/node/dnwbot/node_modules/telebot/lib/updates.js:92:33)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

What I thought it could be:

  • I checked the port and the host multiple times via SQL Query in phpmyAdmin. They are correct.
  • And I enabled in Plesk that ANY host can access the database.
  • The username and password is also correct.

What it should do:

  • Obviously just connect to the database. Nothing more.

Do you habe any clues what it could be?

2

Answers


  1. Chosen as BEST ANSWER

    I finally found the problem: The serveradmin blocked the port on a deeper server level which can't be accessed by Plesk.


  2. Check you have access to remote server database.Try to connect using workbench or any other tool

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search