Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to connect to mongolab host

Tags:

mongodb

mlab

I am trying to connect to mongolab from terminal via below command

 mongo ds061158.mongolab.com:61158/order_it -u <dbuser> -p <dbpassword>

I am getting the below error.

MongoDB shell version: 2.6.3
connecting to: ds061158.mongolab.com:61158/order_it
2014-07-09T13:52:44.890+0530 Error: couldn't connect to server ds061158.mongolab.com:61158 (23.22.170.205), connection attempt failed at src/mongo/shell/mongo.js:148
exception: connect failed

What has to be done in this case?

Thanks in Advance.

like image 361
Hannan Shaik Avatar asked Jul 09 '14 08:07

Hannan Shaik


People also ask

Can't connect to server connection refused MongoDB?

Normally this caused because you didn't start mongod process before you try starting mongo shell. This case worked out for me, i had to do ~>sudo mongod --dbpath /dbpathlocation and then opened the new terminal to run mongo...

Can't connect to MongoDB?

These are some of the solutions: Ensure that your MongoDB instance is running: Compass must connect to a running MongoDB instance. Also check you have installed MongoDB and have a running mongod process. You should also check that the port where MongoDB is running matches the port you provide in the compass connect.

Why is MongoDB not connecting?

However, the improper installation of client and problems with URI string may lead to MongoDB not connecting error. At Bobcares, we often get requests to fix MongoDB not connecting error as part of our Server Management Services. Today, we’ll see how our Support Engineers connect MongoDB via different methods and fix related errors.

How to run MongoDB on localhost?

By default, running the mongo console command will look for mongodb on your localhost, hence the 127.0.0.1 IP which is your local loopback. Also, the default config for mongod should be available on localhost.

How do I create a MongoDB host for Compass?

If you need to create a MongoDB host, consider using MongoDB Atlas . Atlas is a cloud-hosted database-as-a-service which requires no installation, offers a free tier to get started, and provides a copyable URI to easily connect Compass to your deployment. If you need to install Compass, see Download and Install Compass for instructions.

How to check if MongoLab database has upgraded?

Make sure you are using the database username and password not the account username and password from Mlab. Now you can test this on the shell with mongo ds061374.mlab.com:61374/yourdb -u <dbuser> -p <dbpassword> Show activity on this post. Mongolab upgraded their 2.6.x databases to 3.0.x.


1 Answers

It looks like your network is blocking access to that port. I'd recommend contacting your network administrator or trying from a different network.

To test your network connectivity alone (no credentials necessary) you can run this command. This example was run from my unprivileged laptop just now and demonstrates a successful test.

% mongo ds061158.mongolab.com:61158
MongoDB shell version: 2.6.1
connecting to: ds061158.mongolab.com:61158/test
rs-ds061158:PRIMARY> db.runCommand({ping:1});
{ "ok" : 1 }
rs-ds061158:PRIMARY> exit
bye

Our full connectivity troubleshooting guide is here: http://docs.mongolab.com/connecting/#help

Also, feel free to contact us as [email protected] if you'd like us to dig into the specifics of your server or code. We're always happy to help!

Regards,

Jared

like image 151
jared Avatar answered Nov 06 '22 05:11

jared