Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't connect to MySQL server (110) (AWS RDS Instance)

I have this code to connect to a rds instance:

import MySQLdb

USERNAME = 'root'
PASSWORD = 'pass'
DB_NAME = 'databasetest2'

print "Connecting to RDS instance"

conn = MySQLdb.connect ( host = 'mysql-db-instance-database-test2.code.us-east-1.rds.amazonaws.com', user = USERNAME, passwd = PASSWORD, db = DB_NAME, port = 3306)

print "Connected to RDS instance"

But Im having this error:

 Connecting to RDS instance
    Traceback (most recent call last):
      File "mysql.py", line 10, in <module>
        conn = MySQLdb.connect ( host = 'mysql-db-instance-database-test2.code.us-east-1.rds.amazonaws.com', user = USERNAME, passwd = PASSWORD, db = DB_NAME, port = 3306)
      File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
        return Connection(*args, **kwargs)
      File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
        super(Connection, self).__init__(*args, **kwargs2)
    _mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'mysql-db-instance-database-test2.code.us-east-1.rds.amazonaws.com' (110)")

Do you see why Im having this error?

like image 456
UserX Avatar asked Apr 17 '15 18:04

UserX


People also ask

Can't connect to MySQL server on Amazon RDS?

Troubleshoot database level issuesBe sure that you're using the correct user name and password to access the instance from your DB client. Be sure that the user has the database permissions to connect to the DB instance. Check for any resource throttling in Amazon RDS, such as CPU or memory contention.

How do I connect to AWS RDS MySQL database?

Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/ . In the navigation pane, choose Databases to display a list of your DB instances. Choose the name of the MySQL DB instance to display its details. On the Connectivity & security tab, copy the endpoint.

What are some of the common causes why you Cannot connect to a DB instance on AWS?

When you can't connect to a DB instance, the following are common causes: Inbound rules – The access rules enforced by your local firewall and the IP addresses authorized to access your DB instance might not match. The problem is most likely the inbound rules in your security group.


1 Answers

YOu should check two points:

  1. EC2 Security Group assigned to your RDS. Check that incoming port 3306 is open for your RDS SG
  2. RDS VPC - you probably have several and check that it belongs to the same VPC where your EC2 instance is located
like image 188
Evgeniy Kuzmin Avatar answered Sep 20 '22 05:09

Evgeniy Kuzmin