felixge/node-mysql — Issue #170: Error: connect ECONNREFUSED
Author: alexgenovese
Created: 2012-02-16 10:16:57+00:00
State: open

Hello, I'm trying to do a simple connection but I found this error:

node.js:218
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: connect ECONNREFUSED
at errnoException (net.js:672:11)
at Object.afterConnect [as oncomplete] (net.js:663:18)

The code is the following:

var mysql = require('mysql');
var TEST_DATABASE = 'emailmarketing';
var TEST_TABLE = 'campaigns';
var client = mysql.createClient({
user: 'root',
password: 'root',
database: TEST_DATABASE
});

client.query('USE '+TEST_DATABASE);
client.query(
'SELECT * FROM '+TEST_TABLE,
function selectCb(err, results, fields) {
if (err) {
throw err;
}

console.log(results);
console.log(fields);
client.end();
}
);

my list npm is:

├─┬ express@2.5.7
│ ├─┬ connect@1.8.5
│ │ └── formidable@1.0.8
│ ├── mime@1.2.4
│ ├── mkdirp@0.0.7
│ └── qs@0.4.1
├─┬ mail@0.2.3
│ └── reparse@0.1.2
├─┬ mysql@0.9.5
│ └─┬ hashish@0.0.4
│ └── traverse@0.5.2
├─┬ nodemailer@0.3.2
│ ├─┬ mailcomposer@0.1.4
│ │ └── mimelib-noiconv@0.1.6
│ └─┬ simplesmtp@0.1.11
│ └── rai@0.1.5
├─┬ socket.io@0.8.7
│ ├── policyfile@0.0.4
│ ├── redis@0.6.7
│ └─┬ socket.io-client@0.8.7
│ ├── uglify-js@1.0.6
│ ├── websocket-client@1.0.0
│ └── xmlhttprequest@1.2.2
└─┬ socket.io-client@0.8.7
├── uglify-js@1.0.6
├── websocket-client@1.0.0
└── xmlhttprequest@1.2.2

Any help is appreciated.
Thanks
Alex