I am tasked with hosting a website for a class. I need to run client, webserver, and database from three separate nodes as a requirement of the class. I have setup an aws instance and connected it to my vs code through ssh. The issue I am having is when I run node backend.js to establish the connection to the MySQL database it fails one way or another. I am stuck and not sure where to go from here, so any help is appreciated.
I wasn’t expecting this much trouble establishing a connection.
[placeholder]$ node backend.js
Server listening on port 3000
Error connecting to MySQL database: Error: connect ETIMEDOUT
at Connection._handleConnectTimeout (/home/ec2-user/node_modules/mysql/lib/Connection.js:409:13)
at Object.onceWrapper (node:events:631:28)
at Socket.emit (node:events:517:28)
at Socket._onTimeout (node:net:598:8)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7)
--------------------
at Protocol._enqueue (/home/ec2-user/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/home/ec2-user/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/home/ec2-user/node_modules/mysql/lib/Connection.js:116:18)
at Object.<anonymous> (/home/ec2-user/backend.js:17:12)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
at node:internal/main/run_main_module:23:47 {
errorno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
fatal: true
}