When i am trying to run this code i am getting the following error

£可爱£侵袭症+ 提交于 2019-12-01 01:09:05
mongoose.connect('mongod://localhost/students', { useNewUrlParser: true }); 

It should start with mongodb://..., And When you use { useNewUrlParser: true } you should always specify the port number in connection string mongoose reference like given below.

mongoose.connect('mongodb://localhost:27017/students', { useNewUrlParser: true });

here port number 27017 is the default port for MongoDB database.

The host you write is not correct, and it should be. m

mongoose.connect('mongodb://localhost:27017/students', { useNewUrlParser: true });

I have faced the same issue, I just started the mongo in the terminal by command

1) sudo service mongod start 2) mongo

worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!