0
votes

I am trying to connect to my mongo database in my remote server:

$ mongo xxx.xxx.xxx.xx:27017

But I get this error:

MongoDB shell version: 2.6.10 connecting to: xxx.xxx.xxx.xx:27017/test 2016-11-07T05:18:39.140+0000 warning: Failed to connect to xxx.xxx.xxx.xx:27017, reason: errno:111 Connection refused 2016-11-07T05:18:39.142+0000 Error: couldn't connect to server xxx.xxx.xxx.xx:27017 (xxx.xxx.xxx.xx), connection attempt failed at src/mongo/shell/mongo.js:148 exception: connect failed

Any ideas why?

I even have tried to connect it with an username and password but it still fails to connect...

1
In which environment you're trying to run your mongod?David R
it will show startup warnings but working fine, for example i can able to query my dbs and collections.KARTHIKEYAN.A
@DavidR wut do u mean by environment? I'm on linux ubuntu.laukok
Can you show mongo conf cat /etc/mongod.conf there must be a line with bind_ip 127.0.0.1,xx.xx.xx.xx where xx.xx.xx.xx is your public IPMolda
Server of course, that's where you have mongodb installed right?Molda

1 Answers

1
votes

Run this following command :

sudo service mongodb stop
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongod restart
mongo