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
Project ID:
bf51dd68-ec3c-4190-a89e-6f06b2d77090
can you show me a screenshot of your service variables please
Hi @Brody , these are my variables. The URL is not really in use, but I just added it there.
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.
looks like you are not using the DB_PORT variable in your code
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?
that means the mysql package you are using does not support the version of mysql that runs on railway
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!!
was the solution to use mysql2?
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.
doesn't seem like the best option tbh, but if it works for you!
would you recommend this for next time? npm un mysql && npm i mysql2
just use mysql2, isn't it a drop in replacement?
I wasn't sure if this would work on Railway / if mysql2 was available. I couldn't see that option
it's installed by npm, it doesn't really have anything to do with railway
ok, that's good to know! thank you!!
no problem!