The MySQL DB residing in AWS RDS was made to connect with resources in the same VPC. I always had to make it publicly accessible in order to connect to it through MySQL Workbench 8.0 CE in Windows 11. The moment that I used mysql(2) NPM package to connect to it in a NodeJS server running locally (using localhost) on the same network that I used to connect it to the MySQL DB through MySQL Workbench, it connects successfully but then immediately loses the connection. It was weird to me because it was just two hours ago when I connected successfully to it through MySQL Workbench. I tried several other packages such as knex and @aws-sdk/client-rds-data but they all had the same issue. So I went back to MySQL Workbench and the connection failed for the first time although I made sure that the hostname is correct, the port, the username the password, tried to establish a new connection, restarted my PC, made sure MySQL in the RDS is set to publicly accessible, and checked CloudTrail to make sure that no one touched its AWS settings including myself except my changing to its option when I make it publicly accessible.
Checking the logs, I found the following when trying to connect through the code using a valid user:
My public IP address:
The error I get when I am trying to connect to it on MySQL Workbench:
What I did so far but none worked:
- Disabled my network proxy.
- Disabled my Firewall.
- Manually set the DNS to Google DNS.
- Reset my user password in the AWS RDS and tried the new password.
- Enabled the VPN.
Please note that:
- I can connect to the AWS RDS through my Lambda Function in the AWS Cloud in the same VPC.
- The MySQL is running on a pod in the EKS and I can connect to it when executing the pod.
- The Outbound rule of MySQL in the RDS in a Security Group allows all addresses to connect to it, and two other Inbound rules that one of them is public while the other is specific.
My question is: How can I regain my local connection to it? What is the reason for losing the connection in the first place?
Any help will be definitely appreciated.