0

MongoDB is not connecting to my nodejs app earlier it was working fine but I don't know why this is not working when tried to run using shell I get this error

C:\Users\adity>mongo
MongoDB shell version v3.6.5
connecting to: mongodb://127.0.0.1:27017
2019-04-20T09:25:45.799+0530 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017 after 5000ms milliseconds, giving up.
2019-04-20T09:25:45.802+0530 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed

I followed this answer to which I found in StackOverflow this is the link but it still gives the same error.

Anyone please help me to fix this.

while trying to start mongod i get this

C:\Users\adity>mongod
2019-04-19T21:12:16.552-0700 I CONTROL  [initandlisten] MongoDB starting : pid=8888 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-H4VG30N
2019-04-19T21:12:16.552-0700 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2019-04-19T21:12:16.555-0700 I CONTROL  [initandlisten] db version v3.6.5
2019-04-19T21:12:16.558-0700 I CONTROL  [initandlisten] git version: a20ecd3e3a174162052ff99913bc2ca9a839d618
2019-04-19T21:12:16.558-0700 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2o-fips  27 Mar 2018
2019-04-19T21:12:16.559-0700 I CONTROL  [initandlisten] allocator: tcmalloc
2019-04-19T21:12:16.559-0700 I CONTROL  [initandlisten] modules: none
2019-04-19T21:12:16.560-0700 I CONTROL  [initandlisten] build environment:
2019-04-19T21:12:16.560-0700 I CONTROL  [initandlisten]     distmod: 2008plus-ssl
2019-04-19T21:12:16.561-0700 I CONTROL  [initandlisten]     distarch: x86_64
2019-04-19T21:12:16.562-0700 I CONTROL  [initandlisten]     target_arch: x86_64
2019-04-19T21:12:16.562-0700 I CONTROL  [initandlisten] options: {}
2019-04-19T21:12:16.566-0700 I STORAGE  [initandlisten] exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found., terminating
2019-04-19T21:12:16.569-0700 I CONTROL  [initandlisten] now exiting
2019-04-19T21:12:16.569-0700 I CONTROL  [initandlisten] shutting down with code:100
aditya kumar
  • 2,905
  • 10
  • 39
  • 79
  • Is your `mongod` running? if not then start it first. – krishna Prasad Apr 20 '19 at 04:24
  • 1
    Followed the existing answer how exactly? Show the steps you actually did, since the error indicates that the `mongod` process is in fact **not running** on your machine and the steps outlined in that answer show exactly how to rectify that. If you think you have a different problem then it's **up to you to prove** why your problem and question are indeed different. Otherwise, people will simply copy similar answers in response anyway. Edit the question to show why it is indeed different and those steps do not apply here. – Neil Lunn Apr 20 '19 at 04:25
  • @krishnaPrasad i tried that see my question again i had updated it. – aditya kumar Apr 20 '19 at 04:32
  • @NeilLunn i tried to start mongo with both way mongod and mongodb compass(which is gui for mongo) in both way it did not start – aditya kumar Apr 20 '19 at 04:34
  • 2
    So when you look at the output from attempting to start `mongod`, you see `NonExistentPath: Data directory C:\data\db\ not found., terminating`. This is covered in all of those existing answers you have already been pointed to, including the original reference. I suggest you actually **follow the instructions** and do so until you don't receive any more errors. Also please see [Install MongoDB Community Edition on Windows](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/) in the core documentation and **read all of it**. The question is no different to the existing ones. – Neil Lunn Apr 20 '19 at 04:46

0 Answers0