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