2

I have a NodeJS application using MongoDB as the database. I'm using mongoose for mongodb related activities.

I have an account in MongoLab and I use that for my database related activities of my application.

When trying to connect to MongoLab as below from nodejs

mongoose.connect("<db_url_with_username_password>", function(err) {
    if(err)
    {
        console.log("Error is "+err);
        throw err;
    }
});

It's logging the following line

Error is MongoError: connect ECONNREFUSED 54.161.65.217:19058

I thought the server could be down, hence I checked the website online, it's working perfectly.

I pinged the server with the following

ping 54.161.65.217

and it's working fine.

64 bytes from 54.161.65.217: icmp_seq=0 ttl=28 time=271.396 ms
64 bytes from 54.161.65.217: icmp_seq=1 ttl=28 time=268.824 ms

However, When I'm trying to connect using the mongo command to connect, it's failing

mongo 54.161.65.217:19058/<db_name> -u <username> -p <password> 
MongoDB shell version: 3.2.1
connecting to: 54.161.65.217:19058/arogyavath
2016-03-14T10:28:27.200+0530 W NETWORK  [thread1] Failed to connect to 54.161.65.217:19058, reason: errno:61 Connection refused
2016-03-14T10:28:27.201+0530 E QUERY    [thread1] Error: couldn't connect to server 54.161.65.217:19058, connection attempt failed :
connect@src/mongo/shell/mongo.js:226:14
@(connect):1:6

exception: connect failed

I looked around and found the following questions which could be similar to mine Node.js Error: connect ECONNREFUSED ECONNREFUSED error when connecting to mongodb from node.js

But the answers I found there didn't help me fix the issue.

Could the server ip address be blocked from my network or something? How do I fix this?

I would be very glad if someone can point me in the right direction. Thanks in Advance.

Community
  • 1
  • 1
HelpMatters
  • 1,299
  • 1
  • 13
  • 32
  • Can you `ping` or `netcat`? If you cannot then there are either nework issues between the connection or the server is indeed down, despite your assertion that you believe it is up. We cannot really resolve neworking issues for you, and certainly not without providing the host address. – Blakes Seven Mar 14 '16 at 04:30
  • I am able to ping the IP Address. It's working fine. I have updated the question with the IP Address and the port. IP ADDRESS : 54.161.65.217 PORT : 19058 – HelpMatters Mar 14 '16 at 04:37
  • I would suggest you have some firewall rules in between where you are connecting to and the target. I can connect to this without any problem. Of course I cannot authenticate ( and please don't post credentials ) but there is no problem with the connection itself. – Blakes Seven Mar 14 '16 at 05:15
  • You can try giving our troubleshooting guide a try: http://docs.mlab.com/connecting/#help. If you still need help you can email us at support@mlab.com as well. – Chris Chang Mar 14 '16 at 20:04
  • You may also want to talk to your network admin to see if they can provide any help. – Chris Chang Mar 14 '16 at 20:04

0 Answers0