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.

  • 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'
    – Shibily
    Commented Sep 22, 2019 at 14:28
  • 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.
    – Shibily
    Commented Sep 22, 2019 at 17:38
  • Are you using Docker toolbox for this? What version of Docker are you using? Commented Sep 23, 2019 at 18:04

2 Answers 2


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.


I had to enable both DNS Hostname and DNS resolution under the AWS VPC settings.

Sorry for answering late.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.