Answers: <p>As per the error, it looks like the resolution is not happening for host <code>xxxxx-xxxxx-xxxx.xxxxxxxxx.us-east-2.rds.amazonaws.com'</code>. I mean the hostname is not getting resolved to the IP address from inside the container. </p>
  
  <p>You may need to check if the DNS resolver is working properly from inside the container or not. For testing, you can try to use the IP instead of the RDS endpoint hostname and see if it works. </p>
  
Answers: CC BY-SA 4.0
Answers: 2019-09-23T19:40:26.090Z
Answers: 2019-09-23T19:40:26.090Z
Answers: Samit
Answers: <p>I had to enable both DNS Hostname and DNS resolution under the AWS VPC settings.</p>
  <p>Sorry for answering late.</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-04-14T00:56:36.123Z
Answers: 2021-04-14T00:56:36.123Z
Answers: Shibily
Body: <p>I am running a docker swarm cluster and I was trying to connect to a private RDS instance within the same VPC from a docker container which is running in an EC2 within the same VPC but I get an error like <strong>"unknown host"</strong>. I have enabled the database port number(3306) in RDS security group for my EC2 instances.</p>
  
  <p>However, I am able to connect to the database from the host level but not from the container level.</p>
  
Comments: CC BY-SA 4.0
Comments: 2019-09-22T14:28:35.057Z
Comments: This is the error from the docker container: ERROR 2005 (HY000): Unknown MySQL server host 'xxxxx-xxxxx-xxxx.xxxxxxxxx.us-east-2.rds.amazonaws.com'
Comments: Shibily
Comments: CC BY-SA 4.0
Comments: 2019-09-22T17:38:00.363Z
Comments: I found that I am not able to connect to the internet while using an overlay network. I tried with bridge network and was able to connect to the internet and hence RDS.
Comments: Shibily
Comments: CC BY-SA 4.0
Comments: 2019-09-23T18:04:55.897Z
Comments: Are you using Docker toolbox for this?  What version of Docker are you using?
Comments: Wesley Rolnick
Tags: <docker><amazon-rds>
Title: Connect to RDS Private Instance from Docker Container
UserDisplayName: Shibily
ThreadText: # Connect to RDS Private Instance from Docker Container
  
  (Asked by: username_0 on 2019-09-22)
  
  I am running a docker swarm cluster and I was trying to connect to a private RDS instance within the same VPC from a docker container which is running in an EC2 within the same VPC but I get an error like **"unknown host"**. I have enabled the database port number(3306) in RDS security group for my EC2 instances.
  
  However, I am able to connect to the database from the host level but not from the container level.
  
  **Tags:** docker, amazon-rds
  
  > **Comments:**
  > **username_0**: This is the error from the docker container: ERROR 2005 (HY000): Unknown MySQL server host 'xxxxx-xxxxx-xxxx.xxxxxxxxx.us-east-2.rds.amazonaws.com'  
  > **username_0**: I found that I am not able to connect to the internet while using an overlay network. I tried with bridge network and was able to connect to the internet and hence RDS.  
  > **username_1**: Are you using Docker toolbox for this?  What version of Docker are you using?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-09-23. Score: 1
  
  As per the error, it looks like the resolution is not happening for host `xxxxx-xxxxx-xxxx.xxxxxxxxx.us-east-2.rds.amazonaws.com'`. I mean the hostname is not getting resolved to the IP address from inside the container.
  
  You may need to check if the DNS resolver is working properly from inside the container or not. For testing, you can try to use the IP instead of the RDS endpoint hostname and see if it works.
  
  
  ---
  
  ### Answer by username_0 on 2021-04-14. Score: 0
  
  I had to enable both DNS Hostname and DNS resolution under the AWS VPC settings.
  
  Sorry for answering late.
  
  
  ---
  
  