Giter Club home page Giter Club logo

Comments (5)

bhutchins1a avatar bhutchins1a commented on August 29, 2024

Hi, Guys.
Ran into an issue trying to connect with node V 17.4. Plugin is mysql_native_password, user has a password.

JS:

var mysql = require('mysql');

var connection = mysql.createConnection({
	host: 'localhost',
	user: 'root',
	password: 'password',
	database: 'join_us'
});

Get the following error trace:

/Users/david/Projects/mysql_bootcamp/faker/app.js:13
  if (error) throw error;
             ^

Error: connect ECONNREFUSED ::1:3306
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16)
    --------------------
    at Protocol._enqueue (/Users/david/Projects/mysql_bootcamp/faker/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/Users/david/Projects/mysql_bootcamp/faker/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at Connection.connect (/Users/david/Projects/mysql_bootcamp/faker/node_modules/mysql/lib/Connection.js:116:18)
    at Object.<anonymous> (/Users/david/Projects/mysql_bootcamp/faker/app.js:10:12)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  errno: -61,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '::1',
  port: 3306,
  fatal: true
}

After agonizing for a while, I couldn't understand the ::1:3306 part of the error message. Changed 'localhost' in the connection object to 127.0.0.1 and it worked. This is with node.js 17.4

Downgraded node.js to 16.X and kept the host in the connection object as 'localhost' and it worked fine.

Any idea what changed between node.js 16.X and 17.4 that would affect the mysql package?

P.S.: There's no binding address in the MySQL server config file.

from mysql.

dougwilson avatar dougwilson commented on August 29, 2024

Hi, sorry you had trouble. How TCP connections resolve domain name and the errors is all handled by Node.js, which is why changing the Node.js version changes behavior. This module is not actually involved in that behavior.

from mysql.

bhutchins1a avatar bhutchins1a commented on August 29, 2024

Hi, sorry you had trouble. How TCP connections resolve domain name and the errors is all handled by Node.js, which is why changing the Node.js version changes behavior. This module is not actually involved in that behavior.

Thanks for looking at it so quickly, Doug.

from mysql.

dougwilson avatar dougwilson commented on August 29, 2024

No problem. I also checked and in Node.js 17.0 changelog says that the DNS resolution no longer puts IPv4 addresses first, instead they are returned as it comes from the OS. Probably the OS hosts file has ::1 above 127.0.0.1, so Node.js+ will resolve it as IPv6 ::1 instead of 127.0.0.1 on that system.

from mysql.

bhutchins1a avatar bhutchins1a commented on August 29, 2024

Thanks for following up. The Node.js changelog makes it make sense now (awkward sentence structure).

👍👍

from mysql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.