MySQL connection on MWAA Airflow

0

Hi,

I am trying to set up a MySQL connection in MWAA Airflow. I added apache-airflow-providers-mysql, apache-airflow[mysql], and mysqlclient to requirements.txt and I can see in the Cloudwatch logs that the packages installed successfully.

When I try to create the connection I get this error: (2002, "Can't connect to server on 'prod-db.***.com' (115)")

mysql connection error

How do I fix this connection? The database is MySQL hosted on RDS. MWAA and the database are in the same VPC.

Thank you!

Zach
asked 9 months ago884 views
2 Answers
0
Accepted Answer

It turns out this was working the whole time, it's just the functionality to "test" the connection that was returning an error.

Zach
answered 9 months ago
0

Hi,

As explained in the MySQL documentation, The error "(2002) Can't connect to ..." means that one of the following:

  • MySQL server is not running or is not reachable due to a firewall or port blocking service.
  • MySQL client is using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server.

In the context of AWS, you can take the following actions to remediate to this issue:

  • Make sure that the "Host" provided in the MWAA (Airflow) Connection corresponds to the RDS MySQL endpoint. A mistyped or incorrect endpoint could lead to connection issues.
  • Verify that the RDS instance is in the "Available" state. If it's in a different state (e.g., creating, modifying, or in a failure state), it might not accept incoming connections.
  • Ensure that the security group associated with your RDS MySQL instance allows inbound traffic from the MWAA instances on port 3306.
  • Verify that there are no restrictions in network ACL (NACL) rules preventing communication between MWAA and RDS subnets.
  • If you are using a custom DNS setup in your VPC, make sure that DNS resolution is properly configured to resolve the RDS endpoint MySQL correctly.

Best,

Mehdi B.

AWS
Mehdi_B
answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions