ERROR 2003 (HY000): Can't connect to MySQL server on AWS RDS
Asked Answered
P

9

11

I created an external user with '%' hostname to allow remote access. I get the following error while connecting the local MySQL to remote AWS RDS:

ERROR 2003 (HY000): Can't connect to MySQL server on 'instance.cvxqy8tbi2bk.us-east-1.rds.amazonaws.com' (110).

I tried commenting the #bind-address = localhost but no solution. Any pointers for this?

Picot answered 8/3, 2016 at 3:44 Comment(1)
You just have to change bind-address=0.0.0.0 and then restart your MySQL. Hope it will be helpful for youDorsal
S
24

Anyone encountering this issue today should check out this YouTube video at around 6:05:

AWS RDS MySQL Database Setup | Step by Step Tutorial.

In a nutshell, you have to create a new inbound security rule to allow an external connection.

Selfknowledge answered 19/8, 2020 at 18:6 Comment(2)
November 2020, this is still relevant. AWS does provide an option now to set you up real quick with their template settings WHICH appears to be broken since we first need to apply the fix described in the video.Mirabella
June 2022, this is still relevant. Moreover, without the inbound rules is added you cannot access a DB even from AWS cloud shell.Sulphone
T
4

I had the same problem. this solution: When you create database

in the Virtual private cloud (VPC), please choose "Create new VPC"

in the VPC security group, please choose "create new", don't choose "choose existing"

enter image description here

Trend answered 17/2, 2022 at 10:52 Comment(1)
Creating New VPC is a trick that workedAlgesia
S
1

You should diagnose connection to ANY Mysql/Mariadb/RDS connection before changing any server parameter.

Always use this to check connection.

mysql -u username -p  -h your_rds_instance_name

If connection fail, then check network connection(can you ping the instance name from your local system? ), i.e. firewall access, RDS Subnet rules, security groups rules. If the topics too advance for your, then follow the usual quickstart guidelines and tutorial.

Softcover answered 8/3, 2016 at 11:7 Comment(1)
RDS security group for me. My cloud formation templates were defaulting to an old similarly named version. oofPhenix
A
1

This is an access problem.

You need to go to the security group of your database, click on the security group and then navigate to Security Groups and select inbound rules

enter image description here

Click on Edit Inbound rules

enter image description here

Add 2 new rules with Type as "All Traffic" and "Anywhere Ipv4" & "Anywhere Ipv4" for Source.

enter image description here

Save once done. Now you can connect to the MySQL DB

Alberic answered 18/9, 2023 at 14:43 Comment(0)
A
0

"I tried commenting the #bind-address = localhost but no solution. "

No you cannot just comment it out.

If you want to allow remote connections to the MySQL database then you need to bind to your network adapter and not localhost / the loopback adapter.

So you need to get your server IP then:

bind-address = the.srv.ip.is

This is a better question for Server Fault ;)

Abeabeam answered 8/3, 2016 at 3:55 Comment(3)
Hi Craig. Thanks for the quick reply. Could you tell me what do you mean by server ip address ?Picot
Rhea, the server would have a network adapter with an associated IP. This is the remote server. You will connect to this I guess from elsewhere, it is on a different network. So then the server has a network adapter which this IP associated to it. This is what you will need to bind to if you want to allow remote access in MySQL.Abeabeam
Seems @Picot try to jump straight to advanced topics without learning the basic.Softcover
H
0

I faced the same issue, turns out that I had made the database private to the VPC, meaning only instances in the vpc would be allowed to access the databse, so either make the DB public or try to access the database using an instance in your VPC.

Hodgson answered 21/6, 2022 at 11:43 Comment(1)
making the DB public is not a good option and should only be used for public data.Drink
T
0

My problem was solved by setting public accessibility yes. https://aws.amazon.com/premiumsupport/knowledge-center/rds-connectivity-instance-subnet-vpc/

Toadeater answered 16/3, 2023 at 16:25 Comment(1)
This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From ReviewPoyssick
A
0

If the DB instance is in a private subnnet you should be able to connect from the EC2 instance in private VPC after Set up EC2 connection when both EC2 and RDS are in same VPC.

mysql -h <endpoint> -P 3306 -u <mymasteruser> -p

To connect with RDS instance from outside check the followings:

  1. A inbound Security group rule to allow traffic from internet (0.0.0.0/0)
  2. Set Publicly accessible to Yes in 'Connectivity & security'
  3. Still if you are not able to connect then the RDS instance might be launched in one of the private subnets in the same AZ, as shown in console (also check the Subnet group).
  • If Subnet group have private subnets, make the private subnet as a public subnet i.e.; change the route table association of your private subnet with your public route table which is connected with your internet gateway.

Hope it helps!

Ammonic answered 23/8, 2023 at 9:13 Comment(0)
O
-3

change settings to Publicly accessible. by clicking Modify option

Omsk answered 2/9, 2018 at 8:7 Comment(2)
Your answer must be more descriptive!Drucilla
This would only work if the RDS instance was in a public subnet with internet access to begin with. Even then, it's a bad practice to make your db publicly accessible.Mandimandible

© 2022 - 2024 — McMap. All rights reserved.