0

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

10
  • In which environment you're trying to run your mongod? Commented Nov 7, 2016 at 6:03
  • it will show startup warnings but working fine, for example i can able to query my dbs and collections. Commented Nov 7, 2016 at 6:49
  • @DavidR wut do u mean by environment? I'm on linux ubuntu. Commented Nov 7, 2016 at 6:55
  • 1
    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 IP Commented Nov 7, 2016 at 8:50
  • 1
    Server of course, that's where you have mongodb installed right? Commented Nov 7, 2016 at 10:27

1 Answer 1

1

Run this following command :

sudo service mongodb stop
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongod restart
mongo
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.