connecting to remote mongo server results in exception connect failed
Asked Answered
H

2

16

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...

Herbie answered 23/12, 2012 at 10:51 Comment(2)
If you are trying to connect to mongolab then the local mongod isn't relevant you can remove references of it from the question. I tried setting up mongolab account and connecting and got the same error - so maybe its a problem at their end (you can try contacting their support). If you are trying to connect to your local db then you can type just run "mongo" without additional parameters (it will default to connect to the local db).Induce
You might need a fully qualified URL however as said it seems like it should workUndertook
E
10

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

Extortioner answered 23/12, 2012 at 17:16 Comment(1)
Maybe to check the prompt password is correct: ./mongo ds045907.mongolab.com:45907/database -u user -pSarcastic
G
16

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  * * *
Generalship answered 5/1, 2013 at 9:52 Comment(4)
I am having this issue as well and i tried your checks. The call to mongo ds045907.mongolab.com:45907 failed, however the ping worked. I guess this means that I need to let my network administrators know, however not sure what to tell them exactly. Thanks for your help!Mitchellmitchem
If you can ping but can't connect over TCP to the mongo port then most likely the port is being blocked. They'll need to allow traffic on it somehow.Generalship
Oh okay, so i'd need to ask for access to Port 45907. ThanksMitchellmitchem
Since you're not the OP I'm guessing your port number is different. You should use the hostname and port for your server.Generalship
E
10

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

Extortioner answered 23/12, 2012 at 17:16 Comment(1)
Maybe to check the prompt password is correct: ./mongo ds045907.mongolab.com:45907/database -u user -pSarcastic

© 2022 - 2024 — McMap. All rights reserved.