Home  >  Article  >  Database  >  Why Can\'t I Connect to My RDS Instance from My EC2 Instance: Troubleshooting Firewall and DNS Issues?

Why Can\'t I Connect to My RDS Instance from My EC2 Instance: Troubleshooting Firewall and DNS Issues?

Barbara Streisand
Barbara StreisandOriginal
2024-10-26 20:21:30237browse

Why Can't I Connect to My RDS Instance from My EC2 Instance: Troubleshooting Firewall and DNS Issues?

Troubleshooting RDS Connection Issues Between EC2 and RDS Instances

When attempting to establish a connection between an EC2 instance and an RDS instance, various issues can arise, including timeouts and connection failures. This article will delve into a specific problem related to firewall and DNS settings, as indicated by the error message "ERROR 2003 (HY000): Can't connect to MySQL server on 'mysql..us-east-1.rds.amazonaws.com' (110)".

Understanding the Problem

The issue presented stems from the inability to connect to an RDS instance from an EC2 instance, even though both reside within the U.S. East region. Security group configurations have been implemented to allow access, but the connection still fails with a timeout error.

Resolving the Firewall Issue

To resolve this problem, it is necessary to configure the RDS security group to permit incoming connections from the EC2 instance. While the RDS dashboard offers a "Security Groups" option, this is not the relevant setting. For inbound access to the RDS instance's port 3306, it is crucial to edit the Security Group Rules for the RDS instance.

Editing the Inbound Rules for RDS

  1. Navigate to the RDS instances list.
  2. Select the affected instance.
  3. Click on the "Security Group Rules" section.
  4. Switch to the "Inbound rules" tab and press "Edit."
  5. Modify the "Source" field to include the IP address or IPv4 CIDR blocks of the EC2 instance.

Obtaining the EC2 Instance's Private IP

To determine the private IP address of the EC2 instance for the "Source" field:

  • Log into the instance via SSH and run the command "ip addr."
  • Use the EC2 Manager in the browser and refer to the "Private IPs" section within the instance details.

Additional Considerations

  • Ensure that the EC2 instance's own security groups allow outbound connections to the RDS instance's port 3306.
  • Verify that the RDS instance has a security group allowing inbound traffic from the EC2 instance's security group.
  • Check that the RDS instance is running and available.

The above is the detailed content of Why Can\'t I Connect to My RDS Instance from My EC2 Instance: Troubleshooting Firewall and DNS Issues?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn