question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: connect ECONNREFUSED 127.0.0.1:3007

See original GitHub issue

Hi,

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:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
pflugs30commented, Feb 9, 2020

@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!

3reactions
picbenoitcommented, Oct 29, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js Error: connect ECONNREFUSED - Stack Overflow
ECONNREFUSED error means that connection could not be made with the target service (in your case localhost:8080 ).
Read more >
Error: connect ECONNREFUSED 127.0.0.1:80 - Postman
It looks like you're sending a request to localhost:3000 , but your Proxy settings seem to be set to 127.0.0.1: 8080 Is your...
Read more >
Got error: connect ECONNREFUSED 127.0.0.1:1864 #269
Bug report Description when use tsc -p ./scully/tsconfig.scully.json && node scully\bin\scully.js the httpGetJson generate a console log ...
Read more >
Error: connect ECONNREFUSED 127.0.0.1:3306 solved in ...
How to fix Error : connect ECONNREFUSED 127.0.0.1:3306 in node js and mysql is shown.
Read more >
Connect ECONNREFUSED 127.0.0.1:27017 in Mongodb ...
Means that NO mongod instance is running at the given host 127.0.0.1 and port 27017. Yes the solution is to start mongod. Mah_Neh:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found