Error: could’t connect to server 127.0.0.1:27017, connection attempt failed

1. If you open the terminal and execute Mongo directly, it will be prompted that you cannot connect to 127.0.0.1:27017
Reason: No mongoDB service running

2. Run mongoDB service method
Open the terminal and execute Mongod — dbPATH D:\ tools \mongoDB\data\ DB (the path that dbPATH points to is the data storage directory created when installing mongoDB, which is the path of data/ DB and can be modified according to the location of the path created by yourself). The contents shown in the following figure will prove that the first step is OK

3. At this point, open another terminal and execute the mongo local connection successfully

 
 

Read More: