Node.js MySQL - Error: connect ECONNREFUSED Node.js MySQL - Error: connect ECONNREFUSED apache apache

Node.js MySQL - Error: connect ECONNREFUSED


You need to add the value of socket path to the config object:

socketPath: '/var/run/mysqld/mysqld.sock'

In MAMP, you go to http://localhost:8888/MAMP, and you find:

/Applications/MAMP/tmp/mysql/mysql.sock

At the end you have:

var connection = mysql.createConnection({  host     : config.host,  user     : config.user,  password : config.pass,  database : config.db,  socketPath: '/Applications/MAMP/tmp/mysql/mysql.sock'});


Check for your MySQL port in your server.

In MAMP, by default it uses 8889.

Add that to your connection config.

Your MySQL config should look like this.

this.pool = mysql.createPool({  connectionLimit: 10,  host: 'localhost',  user: 'root',  password: 'root',  database: 'todo',  port: '8889'});


Check your xampp server mysql is running or not