Comments (5)
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.
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.
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.
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.
Thanks for following up. The Node.js changelog makes it make sense now (awkward sentence structure).
👍👍
from mysql.
Related Issues (20)
- 腾讯云系统centos7.2安装mysql失败,怎么办麽、 HOT 1
- Error connecting to Aurora DB using the "Amazon RDS" profile HOT 4
- mysql.createPool transaction with loop HOT 1
- Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client HOT 1
- How to catch ER_BAD_FIELD_ERROR HOT 2
- Missing information in Documentation HOT 1
- Multiple insert using array notation HOT 1
- Uncaught exception for "Connection lost: The server closed the connection." HOT 3
- breaks scope HOT 3
- Supported MySQL Versions HOT 2
- readable stream does not seem to support readableLength property HOT 14
- Question - Get query of row HOT 2
- Write cluster failover, pool stuck with read-only cluster HOT 1
- The correct table name when creating the table, with an error: ER_WRONG_TABLE_NAME. HOT 4
- Better type casting of BIT values HOT 3
- the connection string is parsed wrongly HOT 1
- Updating URL parsing to WHATWG URL HOT 2
- RangeError: The value of "offset" is out of range. It must be >= 0 and <= 5254. Received 5261
- getConnection always get timed out
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mysql.