Nodejs failed to connect mongodb

  node.js, question

A few days ago, I made a blog that can send articles in python. I recently learned nodejs and am going to do it again in nodejs. However, when I connected MongoDB, I had a big problem.
Whether I use mongo or mongoose, I will prompt

{ [MongoError: failed to connect to server [localhost:27017] on first connect]
 name: 'MongoError',
 message: 'failed to connect to server [localhost:27017] on first connect' }

First of all, O(∩_∩)O~

1. My MongoDB is on, version 2.0.0. And you can use the mongo connection that MongoDB comes with.
My system is Windows Xp.
3. I can connect MongoDB with python
4.mongoose Version: 4.5.7 “

Post the code

var mongoose = require('mongoose');
 
 mongoose.connect('mongodb://localhost:27017/test',function(err){
 if(err){
 Log ('database connection error!'  );
 Log ('error message: \n\t');
 console.log(err);
 }else{
 console.log('Success!  !  !'  );
 bracket
 })

I tried to delete mongod.lock and try mongodb://127.0.0.1:27017/test connection. Is it a problem with xp? Or is it a question of connection rights? Please advise the great god! ! !

https://docs.mongodb.com/manu …

Starting in version 2.2, MongoDB does not support Windows XP. Please use a more recent version of Windows to use more recent releases of MongoDB.

Although it is curious where you found the version 2.0, it was probably 4 or 5 years ago. However, if you really want to use it this way, you need to find a corresponding 2.0 driver.