Reputation: 511
I am using Loopback with MySql. I am getting following error randomly when I run
nodemon .
or
node .
Web server listening at: http://0.0.0.0:3000 Browse your REST API at http://0.0.0.0:3000/explorer Connection fails: Error: connect ETIMEDOUT It will be retried for the next request. events.js:160 throw er; // Unhandled 'error' event ^ Error: connect ETIMEDOUT at PoolConnection.Connection._handleConnectTimeout
Upvotes: 3
Views: 6921
Reputation: 15995
This seems to be a known issue with MySQL and Loopback that causes the connection to time out under heavy load when Loopback is first starting:
https://github.com/strongloop/loopback-connector-mysql/issues/210
A few possible solutions:
If you're running on a VM or container, increasing the CPU resources may fix the issue.
Set connectTimeout
and acquireTimeout
in the datasource configuration (adjust the values as needed):
{
"mySQL":{
//...
"connectTimeout": 20000,
"acquireTimeout": 20000
}
(https://github.com/strongloop/loopback-connector-mysql/issues/210#issuecomment-258089303)
Here's another option:
Our solution was to remove the initial database connection from the loopback boot by enabling lazyConnect in the datasource config, and then to separately call the datasource connection after the boot is finished. We came to a similar conclusion that CPU stress during the loopback boot causes the db connection to fail.
(https://github.com/strongloop/loopback-connector-mysql/issues/210#issuecomment-758091028)
Upvotes: 1
Reputation: 469
The most probable cause might be that some other service is using the same port, change the port.
I had similar issue with nodemon not with node though, because of not having system32 folder in my path variable.
Upvotes: 0