Bobcares

WeSupport

Call Us! 1-800-383-5193
Call Us! 1-800-383-5193
Call Us! 1-800-383-5193

Need Help?

Emergency Response Time custom

Our experts have had an average response time of 11.06 minutes in March 2021 to fix urgent issues.

We will keep your servers stable, secure and fast at all times for one fixed price.

Unable to connect to MongoDB in Docker container – How we tackle

by | Mar 17, 2021

One of our customers was unable to connect to MongoDB in a docker container. He received the below error message.

warning: Failed to connect to ip:27017, reason: errno:61 Connection refused.

Here at Bobcares, we have seen several such errors while troubleshooting Docker issues as part of our Docker Hosting Support for Docker users, web hosts, and online service providers.

Today we’ll take a look at the cause for this error and how to fix it.

 

Unable to connect to MongoDB in docker container: How we fix

Recently, one of our customers approached us saying that he was trying to connect to MongoDB with mongo ip:27017 (where IP is the name from boot2docker IP) + the port number from docker ps:

27017/tcp
or with -P
0.0.0.0:49155->27017/tcp

Either way, he got the below errors:

warning: Failed to connect to ip:27017, reason: errno:61 Connection refused

Error: couldn't connect to server ip:27017 (IP), connection attempt failed at src/mongo/shell/mongo.js:148 exception: connect failed

Now let us see how our Support Engineers tackle this connection issue.

Here we found that the customer was confused with the internal port with the public port. So, we suggested our customer to use the below command.

$mongo IP:49155

This resolved the error.

We also, provide the below steps to customers if they are on Mac and using Docker Machine.

1. First, get the name of the VM running docker daemon. For that, run the below command.

$ docker-machine ls

2. Next, get the VM’s IP info. For that, run the below command.

$ docker-machine env

3. Finally, connect with the mongo client to the VM IP and the mongo mapped port. For that, run the below command.

$ mongo VM-IP:port

[Need any further assistance in fixing Docker errors? – We are here to help you]

 

Conclusion

In short, we found that this Docker error occurred due to a port issue. Today, we saw the resolution to this error our Support Engineers found.

Are you using Docker based apps?

There are proven ways to get even more out of your Docker containers! Let us help you.

Spend your time in growing business and we will take care of Docker Infrastructure for you.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Docker Support

Spend time on your business, not on your servers.

Managing a server is time consuming. Whether you are an expert or a newbie, that is time you could use to focus on your product or service. Leave your server management to us, and use that time to focus on the growth and success of your business.

TALK TO US Or click here to learn more.
Docker Support

Spend time on your business, not on your servers.

Managing a server is time consuming. Whether you are an expert or a newbie, that is time you could use to focus on your product or service. Leave your server management to us, and use that time to focus on the growth and success of your business.

TALK TO US Or click here to learn more.

Categories:

Tags: