Categories
bookshelf.js express knex.js node.js

Knex:Error Pool2 – Error: connect ECONNREFUSED

I am working with Node.js, Express.js, Bookshelf.js and Knex.js

I am getting following error with default knex pool definition.

Knex:Error Pool2 - Error: connect ECONNREFUSED

That is with following knex definition (default pool.min value is 2)

var knex = require('knex')({
client: 'mysql',
connection: config.connection,
});

I get error

Knex:Error Pool2 - Error: connect ECONNREFUSED
Knex:Error Pool2 - Error: connect ECONNREFUSED

Where as it works fine with following definition.

var knex = require('knex')({
client: 'mysql',
connection: config.connection,
pool: {
min: 0,
max: 10
}
});

I noticed that the error is printed n number of times where n in pool.min value.

Can someone please tell me why this is happening. Although, error is resolved but since I am newbie, I am not able to understand why this is happening.