0

I am learning MongoDB and when I am trying to start mongoDb, it throws me the error below:

C:\Users\Mahadev>mongo
MongoDB shell version: 3.2.3
connecting to: test
2016-02-18T14:45:06.028+0530 W NETWORK  [thread1] Failed to connect to 127.0.0.1
:27017, reason: errno:10061 No connection could be made because the target machi
ne actively refused it.
2016-02-18T14:45:06.029+0530 E QUERY    [thread1] Error: couldn't connect to ser
ver 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:224:14
@(connect):1:6

exception: connect failed

How do I solve the error?

chridam
  • 100,957
  • 23
  • 236
  • 235
Keval Pithva
  • 600
  • 2
  • 5
  • 21
  • 3
    Start server first. https://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/#run-mongodb-community-edition – Alex Blex Feb 18 '16 at 10:18

2 Answers2

0

Try this,

What solved my issue was creating a file startmongo.conf that sets the bind_ipto 127.0.0.1 . After that, I just created a *.bat to start the mongo using something like:

mongod --config c:\mongodb\bin\startmongo.conf

Reference : Mongodb: Failed to connect to 127.0.0.1:27017, reason: errno:10061

Community
  • 1
  • 1
Mad
  • 538
  • 1
  • 10
  • 27
0

May this work

sudo mongod --repair
sudo mongod

(forget about service and start)

Then on a different tab/terminal:

mongo
Hashir Hussain
  • 614
  • 4
  • 8
  • 27