I get the following error:
Warning { MongoError: failed to connect to server [mongodb:27017] on first connect
at Pool. (/Users/michaelks
solve it by following the below steps:
Changed
mongodb://localhost:27017/local
to
localhost/local
And the error gone
In case of remote db in cloud such as ATLAS, you should create whitelist entry 0.0.0.0/0. This allows you to access your cluster ATLAS from any IP address.
I was getting same error while I tried to connect mlab db that is because my organization network has some restriction, I switched to mobile hotspot and it worked.
I ran into this issue serval times, and here is some troubleshooting list
database path
is exist
, the default path in windows in C:\data\db
mongo is running
, to run it go to C:\Program Files\MongoDB\Server\3.4\bin
and run the following:
mongod.exe
mongo.exe
connection string is correct
like mongodb://localhost/database-name
I connected to a VPN and it worked. I was using school's WiFi.
For me,issue was mongo was not running.So first i started "mongod" command in the console.And later in another console tab I have run "mongo". Now the connection is successful. Now run your app your problem should be solved.