Connection to MySQL DB cannot be established

Hi, I'm trying to deploy but it keeps crashing. I triple-checked all variables and they should be working fine for my Group-Project. Locally, everything went smoothly, but deploying seems impossible. This is the error message I receive: Error: connect ETIMEDOUT at Connection._handleConnectTimeout (C:\Users\franz\CodeOP-Projects\Nutrilitious\node_modules\mysql\lib\Connection.js:409:13) at Object.onceWrapper (node:events:627:28) at Socket.emit (node:events:513:28) at Socket._onTimeout (node:net:570:8) at listOnTimeout (node:internal/timers:569:17) at process.processTimers (node:internal/timers:512:7) -------------------- at Protocol._enqueue (C:\Users\franz\CodeOP-Projects\Nutrilitious\node_modules\mysql\lib\protocol\Protocol.js:144:48) at Protocol.handshake (C:\Users\franz\CodeOP-Projects\Nutrilitious\node_modules\mysql\lib\protocol\Protocol.js:51:23) at Connection.connect (C:\Users\franz\CodeOP-Projects\Nutrilitious\node_modules\mysql\lib\Connection.js:116:18) at Object.<anonymous> (C:\Users\franz\CodeOP-Projects\Nutrilitious\model\database.js:18:5) at Module._compile (node:internal/modules/cjs/loader:1254:14) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 { errorno: 'ETIMEDOUT', code: 'ETIMEDOUT', } Any help would be much appreciated!! This is the service ID of my project: bf51dd68-ec3c-4190-a89e-6f06b2d77090
17 Replies
Percy
Percy16mo ago
Project ID: bf51dd68-ec3c-4190-a89e-6f06b2d77090
Brody
Brody16mo ago
can you show me a screenshot of your service variables please
steph_60161
steph_60161OP16mo ago
Hi @Brody , these are my variables. The URL is not really in use, but I just added it there.
steph_60161
steph_60161OP16mo ago
here also my file structure, in case I misplaced something there (e.g. the config file?). It's my first deployment, so maybe I made a mistake there. I've also added the database.js that is throwing the error. as well as the helper.js.
database.js file
helper.js file part 1
helper.js file part 2
Brody
Brody16mo ago
looks like you are not using the DB_PORT variable in your code
steph_60161
steph_60161OP16mo ago
thank you @Brody ! I've changed that in both files. now I am just getting the following error. does that mean I need another type of database?
Brody
Brody16mo ago
that means the mysql package you are using does not support the version of mysql that runs on railway
steph_60161
steph_60161OP16mo ago
Thank you @Brody !!! This was helpful. I googled and followed the instructions here: https://stackoverflow.com/questions/50093144/mysql-8-0-client-does-not-support-authentication-protocol-requested-by-server worked perfectly and the website ois running. Thanks again for all the support!!
Brody
Brody16mo ago
was the solution to use mysql2?
steph_60161
steph_60161OP16mo ago
that was one option but I tried this first and it worked: ALTER USER 'root' IDENTIFIED WITH mysql_native_password BY 'password'; (and added the mySQL password instead of password) and then refreshed the privileges with flush privileges; after that, everything ran smoothly.
Brody
Brody16mo ago
doesn't seem like the best option tbh, but if it works for you!
steph_60161
steph_60161OP16mo ago
would you recommend this for next time? npm un mysql && npm i mysql2
Brody
Brody16mo ago
just use mysql2, isn't it a drop in replacement?
steph_60161
steph_60161OP16mo ago
I wasn't sure if this would work on Railway / if mysql2 was available. I couldn't see that option
Brody
Brody16mo ago
it's installed by npm, it doesn't really have anything to do with railway
steph_60161
steph_60161OP16mo ago
ok, that's good to know! thank you!!
Brody
Brody16mo ago
no problem!
Want results from more Discord servers?
Add your server