MongoDB Error: couldn't connect to server 127.0.0.1:27017 exception: connect failed | mongoDB

MongoDB Error: couldn't connect to server 127.0.0.1:27017 exception: connect failed | mongoDB

Problem : MongoDB shell version v4.4.6 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: No connection could be made because the target machine actively refused it. : connect@src/mongo/shell/mongo.js:374:17 @(connect):2:6 exception: connect failed exiting with code 1 Solution: We have 2 solutions in this case Check Whether your MongoDB files have a data directory if it is not present then go to C: drive and create a folder data and inside that data, folder create another folder named as DB. Now check typing mongo. if it is still showing the same error then go to task manager then in services search for MongoDB Server and check whether it is running or stopped, if stopped then click on start it will start and your MongoDB will now work.... cheers :)