简体   繁体   中英

Unable to connect to MySQL Database on RDS from application hosted outside AWS

I have authorized connection to RDS by adding the CIDRs as mentioned in the AWS documentation.

So I am able to connect and manage my RDS instance from local system(I added my local ip in CIDR)

My application instance is resting on a server that is outside AWS and is unable to connect to the database even after adding my application server IP to CIDR allowing only one IP /32.

when i try to open my application, i get this error

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '<rds endpoint>' (4)

Did others face the same problem? How did you go about solving it? Regards Ravi

Is your application behind a firewall or front-facing? Does it have a public IP or is it using an internal IP on your network? It may be an issue that you may need to allow the front-facing IP access on your security group to access the RDS instance if your application server is behind the firewall.

The issue is fixed now. Realized that my mysql port 3306 was blocked on the server and was not allowing any communication responses.

Thanks for the help though.

edit:
So, here's how the issue was solved. RDS allows incoming connections from two sources. 1. Trusted IP 2. ec2- security group

When allowing connections from any outside IP, we have to add that IP or IP range to the security group in RDS instance. It is available in RDS console. Click here to know more details

The outside server also should allow communications via mysql port(3306), so make sure that you enable 3306 on your application server.

Change your host to the RDS endpoint and test. It should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM