AWS: can't connect to RDS database from my machine

后端 未结 7 1518
野的像风
野的像风 2021-01-30 10:10

The EC2 instance/live web can connect just fine to the RDS database. But when I want to debug the code in my local machine, I can\'t connect to the database and got this error:<

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-30 10:50

    Make sure that your VPC and subnets are wide enought.

    The following CIDR configuration works great for two subnets:

    • VPC 10.0.0.0/16 10.0.0.0 — 10.0.255.255 (65536 addresses)

    • Subnet 1 10.0.0.0/17 10.0.0.0 — 10.0.127.255 (32768 addresses, half)

    • Subnet 2 10.0.128.0/17 10.0.128.0 — 10.0.255.255 (32768 addresses, other half)

    Adjust it if you need three subnets.


    I wasn't being able to connect to my RDS database. I've manually reviewed any detail and everything was alright. There were no indications of any issues whatsoever and I couldn't find any suitable information in the documentation. My VPC was configured with narrow CIDR: 10.0.0.0/22 and each subnet had a 255 addresses. After I've changed CIDR to 10.0.0.0/16 and split it totally between two subnets my RDS connection started to working. It was a pure luck that I've managed to find a source of the problem, because it doesn't make any sense to me.

提交回复
热议问题