I am having trouble connecting to a mysql rds


import pymysql

Database connection parameters

endpoint = 'my-endpoint' # your RDS endpoint username = 'admin' # your RDS username password = 'my-password # your RDS password

Establish a database connection

try: connection = pymysql.connect(host=endpoint, user=username, passwd=password) cursor = connection.cursor()

# Create a new database
cursor.execute("CREATE DATABASE test;")
print("Database 'test' created successfully.")

except pymysql.MySQLError as e: print(f"Error connecting to MySQL Database: {e}") finally: # Close the connection if connection: connection.close()

I am running this simple code and getting the error Error connecting to MySQL Database: (2003, "Can't connect to MySQL server on 'my-server-endpoint' (timed out)") I have ensured that the db is publicly accessible and have added a security group that has multiple rules including accepting all traffic, accepting all ipv4 mysql/aurora connections and all ipv6 mysql/aurora connections.

Here are images of my security settings and my publicly accessible section Inbound Rule Settings

Publicly Accessible

1 Answer
Accepted Answer

You say you have added a security group with multiple rules. If you mean you created one, then from your RDS screen shot it’s NOT configured to use this new security group. You’ll see RDS is using the default security group.

Other thing to note a public RDS instance needs to be in a Public subnet.

profile picture
answered 8 months ago
profile picture
reviewed 2 months ago
profile picture
reviewed 4 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