Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

connecting to remote mongo server results in exception connect failed

Tags:

mongodb

mlab

Running this command in the mongodb installation file from mongodb.org

./mongo ds045907.mongolab.com:45907/database -u user -p password

I changed Database, user, and password for anonymity.

results in this

Error: couldn't connect to server ds045907.mongolab.com:45907 src/mongo/shell/mongo.js:93
exception: connect failed

Maybe i'm being blocked by a server firewall? I have no problem using git or brew or pip...

like image 314
spracketchip Avatar asked Dec 23 '12 10:12

spracketchip


2 Answers

Here are a few things you can try, but you can always feel free to contact us at [email protected]. I'm sure we can get to the bottom of this.

Anonymous mongo shell connection

Mongo will let you connect without authenticating. You can do very little with an unauthenticated connection, but you can use it as a test to separate a connectivity problem from a credentials problem.

% mongo ds045907.mongolab.com:45907
MongoDB shell version: 2.0.7
connecting to: ds045907.mongolab.com:45907/test
> db.version()
2.2.2
> db.runCommand({ping:1})
{ "ok" : 1 }
> exit
bye

If you can connect without authenticating and run the commands as shown above, but trying to connect with authentication fails, then you have a problem with the credentials. If, however, connecting doesn't work even without supplying credentials then you have a connectivity problem.

ping

That server does allow ICMP traffic, so make sure it's reachable from wherever you are.

% ping ds045907.mongolab.com
PING ec2-107-20-85-188.compute-1.amazonaws.com (107.20.85.188): 56 data bytes
64 bytes from 107.20.85.188: icmp_seq=0 ttl=41 time=99.744 ms
64 bytes from 107.20.85.188: icmp_seq=1 ttl=41 time=99.475 ms
64 bytes from 107.20.85.188: icmp_seq=2 ttl=41 time=99.930 ms
^C
--- ec2-107-20-85-188.compute-1.amazonaws.com ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 99.475/99.716/99.930/0.187 ms

traceroute

If ping fails, use traceroute (or tracert on Windows) to try to figure out where the problem is. Once the trace reaches AWS, however, it will trail off. That's normal. AWS prevents traces from seeing too far into their networks. Make sure that the last IP on your list is owned by Amazon using some kind of IP reverse lookup tool (many on the Web).

% traceroute ds045907.mongolab.com
traceroute to ec2-107-20-85-188.compute-1.amazonaws.com (107.20.85.188), 64 hops max, 52 byte packets
 1  192.168.1.1 (192.168.1.1)  1.092 ms  0.865 ms  1.047 ms
 2  192.168.27.1 (192.168.27.1)  1.414 ms  1.330 ms  1.224 ms

            ... snipped to protect the innocent ...

14  72.21.220.83 (72.21.220.83)  87.777 ms
    72.21.220.75 (72.21.220.75)  87.406 ms
    205.251.229.55 (205.251.229.55)  99.363 ms
15  72.21.222.145 (72.21.222.145)  87.703 ms
    178.236.3.24 (178.236.3.24)  98.662 ms
    72.21.220.75 (72.21.220.75)  87.708 ms
16  216.182.224.55 (216.182.224.55)  87.312 ms  86.791 ms  89.005 ms
17  * 216.182.224.55 (216.182.224.55)  91.373 ms *
18  216.182.224.55 (216.182.224.55)  121.754 ms * *
19  * * *
20  * * *
21  * * *
22  * * *
23  * * *
24  * * *
like image 195
jared Avatar answered Oct 22 '22 12:10

jared


It's a connection problem at your side. I tried it but got a login failure message:

MongoDB shell version: 1.6.5

connecting to: ds045907.mongolab.com:45907/database

Mon Dec 24 01:12:31 uncaught exception: login failed

exception: login failed

like image 37
coderLMN Avatar answered Oct 22 '22 12:10

coderLMN