Node. js server mysql database connection timeout problem
Sometimes connection timeouts occur while the Node server is connecting to the database. This Error is Error: Connect ETIMEDOUT. The error position in the code is line 421 to 433 of mysql’s Connection.js file:
Connection.prototype._handleConnectTimeout = function() {
if (this._socket) {
this._socket.setTimeout(0);
this._socket.destroy();
}
var err = new Error('connect ETIMEDOUT');
err.errorno = 'ETIMEDOUT';
err.code = 'ETIMEDOUT';
err.syscall = 'connect';
this._handleNetworkError(err);
};
This error is literally a connection timeout, and then my error is due to the database connection problem, when creating the database should carefully compare the parameters of the problem, like me:
when creating the database connection pool:
pool = mysql.createPool({
host: "127.0.0.1",
user: "user",
password: "",
database: "nodejs",
port: 3306,
});
The header information in the database is:
Source Server : localhost
Source Server Version : 50624
Source Host : localhost:3306
Source Database : nodejs
Target Server Type : MYSQL
Target Server Version : 50624
File Encoding : 65001
It can be seen that there is a problem with the connection address of the server, so the connection was successful after changing to localhost
Read More:
- Solve the problem that node. js USES MySQL to connect econnunion 127.0.0.0.1:3306
- PHP connection to MySQL database error: call to undefined function MySQL_ connect()
- MySQL: if the remote connection using navicatip fails, prompt “is not allowed to connect to this MySQL server”
- JDBC connect to Sql Server to connect to the database–The TCP/IP connection to the host localhost, port 1433 has failed
- How to Fix Node.js connection to MYSQL error.
- Node.js Cannot find module ‘mysql’ ‘express’
- The server just without updating PID file and can’t connect to local MySQL server through socket are solved
- Get connection timeout retry: 1 MySQL errorcode 0, state 08s01 docker container accessing MySQL container is very slow and sometimes interrupted
- [TCP] TCP connection SYN timeout retransmission times and timeout period
- It can’t connect to local MySQL server through socket ‘/ tmp/ mysql.sock ‘(2) “;
- (error when importing database): MySQL 2006-mysql server has gone away
- The MySQL service suddenly hangs up with the error message can’t connect to MySQL server on ‘localhost’ (10061)
- MySQL local connection Error 1130_ The solution of MySQL 1130 error report when remote connection through Navicat for MySQL
- Can’t connect to MySQL server on ‘192.168.64.132‘
- mysql problem solving: mysqladmin: connect to server at’localhost’ failed
- The problem of MySQL database connection failure errno: 1049 error
- Zookeeper connection timeout problem, and refused to connect to solve the problem
- Can’t connect to MySQL server error 111
- MySQL Workbench: Error Code: 2013. Lost connection to MySQL server during query solution
- Cannot connect to MySQL server on “host” (113)