CLIENT AREACall Us 1-800-383-5193


Call Us 1-800-383-5193


Call Us 1-800-383-5193

Need help?

Our experts have had an average response time of 13.52 minutes in October 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:

or with -P>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]



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.


var google_conversion_label = "owonCMyG5nEQ0aD71QM";


Submit a Comment

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




Privacy Preference Center


Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]


Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid


Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie


These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.