calzoneman / sync

Node.JS Server and JavaScript/HTML Client for synchronizing online media
Other
1.46k stars 234 forks source link

Database Initial Connection Error #949

Closed Raintrees25 closed 2 years ago

Raintrees25 commented 2 years ago

Server Problem

Please confirm whether you've tried the following debugging steps:

Description of the Problem

System Information

[ERROR] database: Initial database connection failed: Error: connect ECONNREFUSED ::1:3306 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1195:16)

at Protocol._enqueue (/srv/-MyDir-/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/srv/-MyDir-/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/srv/-MyDir-/node_modules/mysql/lib/Connection.js:116:18)
at /srv/-MyDir-/node_modules/knex/lib/dialects/mysql/index.js:56:18
at new Promise (<anonymous>)
at Client_MySQL.acquireRawConnection (/srv/-MyDir-/node_modules/knex/lib/dialects/mysql/index.js:51:12)
at create (/srv/-MyDir-/node_modules/knex/lib/client.js:237:39)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Raintrees25 commented 2 years ago

Update: I was able to fix this issue by updating the MySQL - Server: parameter in config.yaml from 'localhost' to '127.0.0.1'

Any idea why?

calzoneman commented 2 years ago

Well, from the error message:

[ERROR] database: Initial database connection failed: Error: connect ECONNREFUSED ::1:3306

It's trying to connect to ::1 which is an IPv6 loopback address. I'd guess that your MySQL server was only configured to listen on 127.0.0.1 (IPv4 loopback), but when CyTube tried to connect to localhost, it got resolved to ::1, and so the connection failed.

Sadly this is one of the many pitfalls of IPv4+IPv6 dual stack systems.