Error: connect ECONNREFUSED 127.0.0.1:3007
See original GitHub issueHi,
After a lot of tries to connect to my mysql and mariadb local database. Before open these issue, I read a lot of documentation and issue on mysql / mysql2 / mariadb packages, but all the time same error (I’m new on Node).
I’m on Windows, my Mysql (3306) and Mariadb (3307) servers are running with WAMP. No problem to connect it for all my PHP Projects.
My node version is v10.13.0.
Here is my try :
let mysql = require('mysql2'),
connection = mysql.createConnection({
host : process.env.DB_HOST,
port : process.env.DB_PORT,
user : process.env.DB_USER,
password : process.env.DB_PASSWORD,
database : process.env.DB_DATABASE,
});
connection.query(
'SELECT * FROM consumerlive_respondent WHERE status=20 LIMIT 10',
function(err, results, fields) {
console.log(err);
console.log(results); // results contains rows returned by server
console.log(fields); // fields contains extra meta data about results, if available
}
);
Here is my env file :
DB_HOST=127.0.0.1 DB_PORT=3007 DB_USER=root DB_PASSWORD= DB_DATABASE=colorado
With all packages (mysql, mysql2, mariadb), I obtain the following error :
{ Error: connect ECONNREFUSED 127.0.0.1:3007
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3007,
fatal: true }
I understand that maybe the problem is comming from node and not from mysql2, but how can I fix it ?
I also try with by using socketPath like ‘\\.\pipe\MySQL’ or ‘/tmp/mariadb.sock’ as suggested on mariadb documentation, but this is not working to :
{ Error: connect ENOENT \\.\pipe\MySQL
at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'connect',
address: '\\\\.\\pipe\\MySQL',
fatal: true }
Thank you for your help,
Ben
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
@picbenoit Thank you for taking the time to post this issue. Thanks to the magic of Google search, i found my way to this thread and found that I, too, had incorrectly typed “3007” instead of “3307”. I really appreciate the nudge in the right direction!
Hi @sidorares
Thank you for your answer. I loose more than 1/2 day of work on this issue. After a new try, I create again my env file and finally working. I saw that I made a mistake on the port that is not “3007” but “3307”.
Apologies,
Ben.