Thursday, 20 April 2017

How can I get more information on why my MySQL connection gets ECONNREFUSED?

I'm trying to use promise-mysql (node module) to connect to a MySQL instance, but it fails with ECONNREFUSED. Here's the entire error:

{ Error: connect ECONNREFUSED 172.18.0.6:3306
    at Object.exports._errnoException (util.js:1018:11)
    at exports._exceptionWithHostPort (util.js:1041:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
    --------------------
    at Protocol._enqueue (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:141:48)
    at Protocol.handshake (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:52:41)
    at Connection.connect (/usr/src/app/node_modules/mysql/lib/Connection.js:130:18)
    at connect (/usr/src/app/node_modules/promise-mysql/lib/connection.js:18:33)
    at /usr/src/app/node_modules/promise-mysql/lib/connection.js:52:9
    at Promise._execute (/usr/src/app/node_modules/bluebird/js/release/debuggability.js:300:9)
    at Promise._resolveFromExecutor (/usr/src/app/node_modules/bluebird/js/release/promise.js:483:18)
    at new Promise (/usr/src/app/node_modules/bluebird/js/release/promise.js:79:10)
    at new connection (/usr/src/app/node_modules/promise-mysql/lib/connection.js:51:12)
    at Object.exports.createConnection (/usr/src/app/node_modules/promise-mysql/index.js:6:12)
    at Context.<anonymous> (/usr/src/app/test/default-parameters.test.js:9:10)
    at callFn (/usr/src/app/node_modules/mocha/lib/runnable.js:345:21)
    at Hook.Runnable.run (/usr/src/app/node_modules/mocha/lib/runnable.js:337:7)
    at next (/usr/src/app/node_modules/mocha/lib/runner.js:309:10)
    at Immediate.<anonymous> (/usr/src/app/node_modules/mocha/lib/runner.js:339:5)
    at runCallback (timers.js:666:20)
    at tryOnImmediate (timers.js:639:5)
    at processImmediate [as _immediateCallback] (timers.js:611:5)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '172.18.0.6',
  port: 3306,
  fatal: true }

I have no idea why this is happening. How can I get more information on why the connection is refused?

With "more information" I mean stuff like:

  • Is this because of invalid credentials?
  • Is the host unreachable?
  • Is the host reachable but the MySQL server down?
  • Are we hitting a MySQL connection limit?
  • Are there gnomes in my computer trying to make me mad?


via Lars Nyström

No comments:

Post a Comment