且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Mongodb:首次连接时无法连接到服务器

更新时间:2023-02-04 08:57:05

要连接mongodbmongoose一起使用,可以使用:

To connect to mongodb with mongoose, you can use :

mongoose.connect('mongodb://localhost/users_test');

mongoose.connect('localhost/users_test');

mongoose.connect('localhost','users_test');

但不是mongoose.connect('mongodb:localhost/users_test');,它与正确的主机名(mongodb而不是localhost)不匹配

But not mongoose.connect('mongodb:localhost/users_test');, it doesnt match the right hostname (mongodb instead of localhost)