Bobcares

MongoDB port 27017 not working – Rapid ways to fix it

by | Sep 13, 2019

While managing MongoDB, it’s very common to see Error: couldn’t connect to server 127.0.0.1:27017.

It’s loud and clear that Mongo shell couldn’t speak to the MongoDB server.

And the reasons for the error can be incorrect MongoDB settings, firewall restrictions and many more.

At Bobcares, we often get requests to fix MongoDB port 27017 not working error as part of our Server Management Services.

Today, let’s get into the details and see how our Support Engineers fix MongoDB port errors.

 

How we fix common MongoDB port errors

At Bobcares, where we have more than a decade of expertise in managing servers, we see many customers face problems while managing MongoDB.

Now let’s see the major reasons for MongoDB errors and how our Support Engineers fix the top errors.

 

1. Incorrect IP or port

Recently, one of our customers contacted us with a problem related to MongoDB port connection. When the customer tried to restart the MongoDB, he was getting an error like,

mongo
MongoDB shell version: 2.2.1
connecting to: test
Fri Nov 9 16:44:06 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
exception: connect failed

Moreover, an attempt to access MongoDB tool resulted in the error:

In general, this happens when the address like host or IP was wrong or that it is not running on the server.

Therefore, our Database Engineers edited /etc/mongodb.conf and corrected the settings. We updated the bind IP of the MongoDB to accept connection from outside and also confirmed that the port 27017 is open.

That fixed the problem and MongoDB started accepting connections.

 

2. Insufficient storage space

Similarly, another customer had the same error, mongo MongoDB shell version: 2.4.9 connecting to: test Sun May 8 22:10:15.641 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145 exception: connect failed while restarting the MongoDB.

Looking into the MongoDB log file, located in /var/log/mongodb/mongodb.log, we found the reason as

ERROR: Insufficient free space for journal files
Please make at least 3379MB available in /var/lib/mongodb/journal or use --smallfiles

This error occurs when the space allocated to disk is insufficient to store the journal files. Also, the journal allocation is required to store a minimum of 3 GB space to create and store journal files.

So, our Support Engineers solved the error by executing these steps.

We opened the startup file at  /etc/init.d/mongod and changed from

daemon –user “$MONGO_USER” $NUMACTL $mongod $OPTIONS –nounixsocket

to

daemon –user “$MONGO_USER” $NUMACTL $mongod $OPTIONS –nounixsocket –smallfiles

 

3. Problem with mongod service

Normally this error caused when didn’t start the mongod process before start mongo shell. So, our Support Engineers used the following steps to solve the error.

1. Initially, we removed the .lock file by executing

rm /var/lib/mongodb/mongod.lock

2. Then, we repaired the MongoDB

mongod –repair

3. After that, we started the mongod server

service mongod start

4. Finally, we started the mongo client

mongo

That’s it.

 

[Need assistance to fix MongoDB port errors? We’ll help you.]

 

Conclusion

In short, MongoDB port 27017 not working error may happen when there is insufficient storage space for journal files on disk or incorrect settings in the mongodb.conf file, firewall restrictions, etc. Today, we saw the various reasons for MongoDB port errors and how our Support Engineers fix them.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

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]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

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
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

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

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

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.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF