0

When I enter the command to connect 'mongo --host 127.0.0.1:27017' I don't know why I am getting this error, it used to work before. Following the M103 Tutorial on MongoDB University

MongoDB shell version v3.6.16
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
2020-01-26T17:51:23.154+0000 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2020-01-26T17:51:23.155+0000 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:263:13
@(connect):1:6
  • Does this answer your question? [Cannot connect to mongodb errno:61 Connection refused](https://stackoverflow.com/questions/23418134/cannot-connect-to-mongodb-errno61-connection-refused) – whoami - fakeFaceTrueSoul Jan 26 '20 at 18:48

4 Answers4

0

Can you check your mongdb service is running or not. If yes then can you restart the service and try again. Use below command to restart the service

service mongodb restart
0

Authentication via Kerberos is supported only in (liable to pay costs) MongoDB Enterprise edition, do you use that one?

Check whether mongod service is started.

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
  • yes the mongod service is started yet I am getting same error for using just mongo or even with adding username and password along with it – Sachin Sheelavant Jan 27 '20 at 04:26
0

just try: mongo

because 27017 is the default

are you sure your mongod is running? if the machine has rebooted then mongod must be relaunched

Cahaba Data
  • 624
  • 1
  • 4
  • 4
0

I got the same error message because mongo could not access my database data path.

Mongo log showed this error:

I STORAGE  [initandlisten] exception in initAndListen: NonExistentPath: Data directory /my_unrecognized_path/data/db not found., terminating

Hope this helps.