Mongodb: failed to connect to server on first connect

前端 未结 13 2984
陌清茗
陌清茗 2020-12-15 15:52

I get the following error:

Warning { MongoError: failed to connect to server [mongodb:27017] on first connect
    at Pool. (/Users/michaelks         


        
13条回答
  •  暖寄归人
    2020-12-15 16:19

    To connect to mongodb with mongoose, you can use :

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

    or

    mongoose.connect('localhost/users_test');
    

    or

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

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

提交回复
热议问题